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 memThreshold memory tracking optimization #18480

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

ronawho
Copy link
Contributor

@ronawho ronawho commented Sep 28, 2021

#18465 optimized memory leak tracking to avoid taking a lock when the real
allocation size is below memThreshold, but there were a few bugs in
the initial implementation.

For cases where the memory layer doesn't support chpl_real_alloc_size
(CHPL_MEM=cstdlib) we weren't handling the unknown size sentinel so we
weren't ever running the free hook, which made it look like we were
leaking all memory. Fix that to run the hook if the "real size" is 0
(the unknown sentinel.)

This was also broken under configurations that separately allocate
arrays (like CHPL_COMM=ugni). For those configs we were taking a comm
layer allocation and trying to ask jemalloc for the size of it, but this
results in mixed allocator calls, which is undefined behavior. Fix that
by making the higher level interface compute the size and passing it in
instead of computing it below the level where we know what allocator
memory came from.

18465 optimized memory leak tracking to avoid taking a lock when the real
allocation size is below `memThreshold`, but there were a few bugs in
the initial implementation.

For cases where the memory layer doesn't support `chpl_real_alloc_size`
(`CHPL_MEM=cstdlib`) we weren't handling the unknown size sentinel so we
weren't ever running the free hook, which made it look like we were
leaking all memory. Fix that to run the hook if the "real size" is 0
(the unknown sentinel.)

This was also broken under configurations that separately allocate
arrays (like `CHPL_COMM=ugni`). For those configs we were taking a comm
layer allocation and trying to ask jemalloc for the size of it, but this
results in mixed allocator calls, which is undefined behavior. Fix that
by making the higher level interface compute the size and passing it in
instead of computing it below the level where we know what allocator
memory came from.

Signed-off-by: Elliot Ronaghan <ronawho@gmail.com>
@ronawho ronawho merged commit e063d68 into chapel-lang:main Sep 29, 2021
@ronawho ronawho deleted the fix-memtracking branch September 29, 2021 00:59
Copy link
Member

@gbtitus gbtitus left a comment

Choose a reason for hiding this comment

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

👍

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.

2 participants