Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-4752

ObjectPool should not do extra dynamic memory allocation

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Impala 2.8.0
    • Fix Version/s: Impala 2.9.0
    • Component/s: Backend
    • Labels:
      None

      Description

      The current ObjectPool implementation is inefficient because it allocates a wrapper object for every object stored in the pool. This could potentially double the number of dynamic memory allocations for small objects.

      Instead we should rework the class to avoid this. E.g. storing a function pointer instead of the wrapper class.

        Activity

        Hide
        tarmstrong Tim Armstrong added a comment -

        IMPALA-4752: make ObjectPool more efficient

        Previously it was implemented as a vector of pointers to
        dynamically allocated wrapper objects, where each wrapper object
        stored a pointer to the object and a pointer to a vtable, which
        had a pointer to a destructor, which then calls the actual
        object's destructor.

        Instead of doing this, this patch changes ObjectPool to stores
        the object pointer and function pointer inline in the vector.
        This avoids an unnecessary malloc() and free() pair per object.

        Testing:
        Ran core tests, which should exercise this heavily during query
        execution.

        Change-Id: I1e6a40ac798fa64da4767f530c48710cba623ea5
        Reviewed-on: http://gerrit.cloudera.org:8080/5666
        Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
        Tested-by: Impala Public Jenkins

        Show
        tarmstrong Tim Armstrong added a comment - IMPALA-4752 : make ObjectPool more efficient Previously it was implemented as a vector of pointers to dynamically allocated wrapper objects, where each wrapper object stored a pointer to the object and a pointer to a vtable, which had a pointer to a destructor, which then calls the actual object's destructor. Instead of doing this, this patch changes ObjectPool to stores the object pointer and function pointer inline in the vector. This avoids an unnecessary malloc() and free() pair per object. Testing: Ran core tests, which should exercise this heavily during query execution. Change-Id: I1e6a40ac798fa64da4767f530c48710cba623ea5 Reviewed-on: http://gerrit.cloudera.org:8080/5666 Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com> Tested-by: Impala Public Jenkins

          People

          • Assignee:
            tarmstrong Tim Armstrong
            Reporter:
            tarmstrong Tim Armstrong
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development