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 threshold to proxy lib to call system allocator #883

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ldorau
Copy link
Contributor

@ldorau ldorau commented Nov 8, 2024

Description

Add threshold to proxy lib to call system allocator
when a size is less than the given threshold.

Ref: #894

Requires:

Checklist

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly

@ldorau ldorau force-pushed the Add_threshold_to_proxy_lib_to_call_system_allocator branch 10 times, most recently from 8bfade2 to 2a5fb9e Compare November 12, 2024 08:47
@ldorau ldorau changed the title [WIP] Add threshold to proxy lib to call system allocator Add threshold to proxy lib to call system allocator Nov 12, 2024
@ldorau ldorau force-pushed the Add_threshold_to_proxy_lib_to_call_system_allocator branch from 2a5fb9e to 4cdba02 Compare November 12, 2024 08:57
@ldorau ldorau marked this pull request as ready for review November 12, 2024 08:57
@ldorau ldorau requested a review from a team as a code owner November 12, 2024 08:57
@ldorau ldorau force-pushed the Add_threshold_to_proxy_lib_to_call_system_allocator branch from 4cdba02 to 0d3f0c7 Compare November 12, 2024 11:32
Signed-off-by: Lukasz Dorau <[email protected]>
Do not assert(ptr) in umfMemoryTrackerGetAllocInfo(),
return UMF_RESULT_ERROR_INVALID_ARGUMENT instead.
Replace LOG_WARN() with LOG_DEBUG().
Add utils_env_var_get_str() to utils_common.
Use utils_env_var_get_str() inside utils_env_var_has_str()
and utils_is_running_in_proxy_lib().

Signed-off-by: Lukasz Dorau <[email protected]>
@ldorau ldorau force-pushed the Add_threshold_to_proxy_lib_to_call_system_allocator branch from 0d3f0c7 to 7c781ef Compare November 12, 2024 11:34
UMF_PROXY="size.threshold=128"
UMF_LOG="level:debug;flush:debug;output:stderr;pid:yes"
LD_PRELOAD=./lib/libumf_proxy.so
ctest --output-on-failure -E provider_file_memory_ipc
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have a test where you use umfPoolByPtr() to check allocs smaller than threshold were not registered in the tracker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add a test for that

src/proxy_lib/proxy_lib.c Outdated Show resolved Hide resolved
src/libumf.c Show resolved Hide resolved
Add a size threshold to proxy lib to call system allocator
when the size is less than the given threshold.

Signed-off-by: Lukasz Dorau <[email protected]>
Comment on lines 309 to 417
if (Proxy_pool) {
if (!was_called_from_umfPool && Proxy_pool &&
(umfPoolByPtr(ptr) == Proxy_pool)) {
was_called_from_umfPool = 1;
void *new_ptr = umfPoolRealloc(Proxy_pool, ptr, size);
was_called_from_umfPool = 0;
return new_ptr;
}

assert(0);
if (threshold_value) {
return system_realloc(ptr, size);
}

Copy link
Contributor

@lplewa lplewa Nov 8, 2024

Choose a reason for hiding this comment

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

Please add test
ptr = Malloc(threshold_value + 1)
realloc(ptr, threshold_value - 1)

and vice versa.
ptr = Malloc(threshold_value - 1)
realloc(ptr, threshold_value + 1)

Both cases check then umfPoolByPtr if it returns expected value.

(atm in this PR we are not supporting this correctly - if we increasing or decrease size of allocation thru realoc we should "realloc this allocation" to correct allocator.

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