Skip to content

Correct the actual allocated size from allocator when call sdsRedize to align the logic with sdsnewlen function.#476

Merged
madolson merged 2 commits into
valkey-io:unstablefrom
zhulipeng:sds_header
May 16, 2024
Merged

Correct the actual allocated size from allocator when call sdsRedize to align the logic with sdsnewlen function.#476
madolson merged 2 commits into
valkey-io:unstablefrom
zhulipeng:sds_header

Conversation

@zhulipeng

@zhulipeng zhulipeng commented May 9, 2024

Copy link
Copy Markdown
Member

This patch try to correct the actual allocated size from allocator
when call sdsRedize to align the logic with sdsnewlen function.

Maybe the #453 optimization should depend on this.

@zhulipeng zhulipeng force-pushed the sds_header branch 2 times, most recently from 1a73354 to 9b30c8a Compare May 9, 2024 06:20
@codecov

codecov Bot commented May 9, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.84%. Comparing base (546cef6) to head (41f32de).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable     #476   +/-   ##
=========================================
  Coverage     69.84%   69.84%           
=========================================
  Files           109      109           
  Lines         61797    61801    +4     
=========================================
+ Hits          43160    43163    +3     
- Misses        18637    18638    +1     
Files Coverage Δ
src/sds.c 87.01% <100.00%> (+0.09%) ⬆️

... and 11 files with indirect coverage changes

@poiuj

poiuj commented May 9, 2024

Copy link
Copy Markdown
Contributor

Right, I did very similar changes. Didn't push yet.

@zhulipeng zhulipeng changed the title Correct the actual allocated size from allocator when call sdsRedize to align the logic with sdsnewlen function [Fix]Correct the actual allocated size from allocator when call sdsRedize to align the logic with sdsnewlen function. May 9, 2024
@zhulipeng zhulipeng changed the title [Fix]Correct the actual allocated size from allocator when call sdsRedize to align the logic with sdsnewlen function. Correct the actual allocated size from allocator when call sdsRedize to align the logic with sdsnewlen function. May 9, 2024
Comment thread src/sds.c Outdated

@madolson madolson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, can you move the tests to the new framework?

Signed-off-by: Lipeng Zhu <[email protected]>
@poiuj poiuj mentioned this pull request May 15, 2024
@zhulipeng

Copy link
Copy Markdown
Member Author

This looks good to me, can you move the tests to the new framework?

Done.

@madolson madolson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice to have, but not necessarily in the scope of this PR, is we should probably add more checks that sdsalloc() is actually always equal to the underlying zmalloc allocation size.

@madolson madolson merged commit 7a9951f into valkey-io:unstable May 16, 2024
@zhulipeng zhulipeng deleted the sds_header branch May 16, 2024 01:30
@poiuj

poiuj commented May 16, 2024

Copy link
Copy Markdown
Contributor

Just to clarify, underlying allocation size equals to sdsalloc() + header size + null terminator. sdsAllocSize() should calculate it.

@madolson madolson requested review from ranshid and removed request for ranshid May 16, 2024 16:53
@madolson

madolson commented May 19, 2024

Copy link
Copy Markdown
Member

srgsanky pushed a commit to srgsanky/valkey that referenced this pull request May 19, 2024
…to align the logic with sdsnewlen function. (valkey-io#476)

This patch try to correct the actual allocated size from allocator
when call sdsRedize to align the logic with sdsnewlen function.

Maybe the valkey-io#453 optimization
should depend on this.

Signed-off-by: Lipeng Zhu <[email protected]>
@zhulipeng

Copy link
Copy Markdown
Member Author

@madolson Sure, I will take a look and try to reproduce in local.

adetunjii pushed a commit to adetunjii/valkey that referenced this pull request May 22, 2024
…to align the logic with sdsnewlen function. (valkey-io#476)

This patch try to correct the actual allocated size from allocator
when call sdsRedize to align the logic with sdsnewlen function.

Maybe the valkey-io#453 optimization
should depend on this.

Signed-off-by: Lipeng Zhu <[email protected]>
Signed-off-by: Samuel Adetunji <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants