Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zfree_with_size to optimize sdsfree since we can get zmalloc_size from the header #453

Merged
merged 11 commits into from
Jun 19, 2024

Commits on Jun 3, 2024

  1. Add zfree_with_size

    zfree updates memory statistics. It gets the size of the buffer from
    jemalloc by calling zmalloc_size. This operation is costly. We can
    avoid it if we know the buffer size. For example, we can calculate
    size of sds from the data we have in its header.
    
    This commit introduces zfree_with_size function that accepts both
    pointer to a buffer, and its size. zfree is refactored to call
    zfree_with_size.
    
    sdsfree uses the new interface for all but SDS_TYPE_5.
    
    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    0a2d984 View commit details
    Browse the repository at this point in the history
  2. Fix sdsAllocSize for SDS_TYPE_5

    sdsalloc returns sds's length for SDS_TYPE_5. It's not correct for
    SDS_TYPE_5.
    
    This patch makes sdsAllocSize call zmalloc_size for
    SDS_TYPE_5. sdsalloc is a lower level function that continues to
    return length for SDS_TYPE_5.
    
    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    2310767 View commit details
    Browse the repository at this point in the history
  3. Do not include zmalloc into sds.c

    Instead of zmalloc_size use s_malloc_size.
    
    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    37ad930 View commit details
    Browse the repository at this point in the history

Commits on Jun 11, 2024

  1. Apply suggestions from code review

    Change the doc string for `zfree_with_size`
    
    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    21acd10 View commit details
    Browse the repository at this point in the history
  2. Update zfree_with_size() docstring

    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    0c2048d View commit details
    Browse the repository at this point in the history
  3. Revert Makefile changes pushed by mistake

    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    72e6b28 View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2024

  1. Make zfree_with_size work correctly on systems without malloc_size

    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    2f96c40 View commit details
    Browse the repository at this point in the history
  2. Update zfree_internal docstring and add assert

    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    19f8f36 View commit details
    Browse the repository at this point in the history
  3. Include serverassert.h in zmalloc.c

    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    195a4a9 View commit details
    Browse the repository at this point in the history

Commits on Jun 18, 2024

  1. Apply madolson's suggestion on zfree_internal

    Signed-off-by: Vadym Khoptynets <[email protected]>
    poiuj committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    017941d View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2024

  1. Update src/zmalloc.c

    Signed-off-by: Madelyn Olson <[email protected]>
    madolson authored Jun 19, 2024
    Configuration menu
    Copy the full SHA
    1a3a6d6 View commit details
    Browse the repository at this point in the history