-
Notifications
You must be signed in to change notification settings - Fork 35
[CTL] Add disjoint pool allocation balance counter #1334
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
base: main
Are you sure you want to change the base?
Conversation
6c4e59a
to
ba5c390
Compare
src/pool/pool_disjoint.c
Outdated
static const umf_ctl_node_t CTL_NODE(disjoint)[] = {CTL_LEAF_RW(name), | ||
CTL_NODE_END}; | ||
// CTL: allocation counters | ||
atomic_int counter_alloc_balance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\include\vcruntime_c11_stdatomic.h(16,1): error C1189: #error: "C atomics require C11 or later" [D:\a\unified-memory-framework\unified-memory-framework\build\src\umf.vcxproj]
(compiling source file '../../src/pool/pool_disjoint.c')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should use our utils from utils_concurrency.h
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ba5c390
to
3bf6fd7
Compare
src/pool/pool_disjoint.c
Outdated
@@ -745,7 +761,7 @@ umf_result_t disjoint_pool_initialize(umf_memory_provider_handle_t provider, | |||
void *disjoint_pool_malloc(void *pool, size_t size) { | |||
disjoint_pool_t *hPool = (disjoint_pool_t *)pool; | |||
void *ptr = disjoint_pool_allocate(hPool, size); | |||
|
|||
atomic_fetch_add(&counter_alloc_balance, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use utils_atomic_increment_u64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
3bf6fd7
to
9dce66e
Compare
9dce66e
to
0609557
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might also be useful to store total allocated size, not just the number of allocations.
src/pool/pool_disjoint.c
Outdated
static const umf_ctl_node_t CTL_NODE(disjoint)[] = {CTL_LEAF_RW(name), | ||
CTL_NODE_END}; | ||
// CTL: allocation counters | ||
uint64_t allocation_balance = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -33,6 +33,7 @@ static char *DEFAULT_NAME = "disjoint"; | |||
struct ctl disjoint_ctl_root; | |||
static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT; | |||
|
|||
// CTL: name attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this something we could implement generically for any pool implementation in the umfPoolAlloc/umfPoolFree interface?
// CTL: allocation counters | ||
uint64_t allocation_balance = 0; | ||
|
||
static int CTL_READ_HANDLER(allocation_balance)( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have docs that list all ctl interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will prepare the docs after this PR, which we discussed previously (with @lplewa @bratpiorka).
cef102e
to
d30e9f9
Compare
d30e9f9
to
2c7329a
Compare
Description
Checklist