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

fix: fix zmalloc_size on macos #2646

Merged
merged 3 commits into from
Feb 23, 2024
Merged

fix: fix zmalloc_size on macos #2646

merged 3 commits into from
Feb 23, 2024

Conversation

andydunstall
Copy link
Contributor

Fixes hset_family_test tests on MacOS

Looks like zmalloc_size isn't defined properly on Mac, so zmalloc uses src/redis/zmalloc_mi.c definition but zmalloc_size uses malloc_size

void *zp = zmalloc(10);
cout << "zmalloc; zmalloc_size " << zmalloc_size(zp) << endl;  // 0
cout << "zmalloc; malloc_size " << malloc_size(zp) << endl;  // 0
cout << "zmalloc; zmalloc_usable_size " << zmalloc_usable_size(zp) << endl;  // 16
void *mp = malloc(10);
cout << "malloc; malloc_size " << malloc_size(mp) << endl;  // 16
cout << "malloc; zmalloc_size " << zmalloc_size(mp) << endl;  // 16

This just copies the USE_ZMALLOC_MI branch from libc into macos branch (I don't really understand this allocator stuff but with this the hset_family_test tests pass running locally on Mac - will run rest of the tests on mac)

@romange romange marked this pull request as ready for review February 23, 2024 07:47
@romange
Copy link
Collaborator

romange commented Feb 23, 2024

Added some of my fixes as well. Proof that it is passing unit tests: https://github.com/dragonflydb/dragonfly/actions/runs/8006667920

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

Hi Andy, thank you for fixing this!

I suppose you have a mac? Can I sincerely ask you to try something for me. I would like to understand why this doesn't fail on Redis, since they use the exact same header on macos. My assumption is that Redis uses jemalloc so they actually call je_malloc_usable_size(p). If you do have a mac and you are happy to try out you can add an #error to check out which path gets exercised in the header. If it does exercises the #elif defined(__APPLE__) instead this is something that we should probably take a look at.

I pre approve but I would like this to be investigated a little more

p.s. I rerun a daily job to see the failure on the CI as well

@romange
Copy link
Collaborator

romange commented Feb 23, 2024 via email

@kostasrim
Copy link
Contributor

They do not have exactly the same header. We use mi_malloc, they do not. I changed this header to fit our requirements

I see, cheers!

@romange romange merged commit 47171c4 into main Feb 23, 2024
13 checks passed
@romange romange deleted the fix-mac-zmalloc-size branch February 23, 2024 15:39
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.

None yet

3 participants