-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Define gc counted allocator functions with libc API #12034
Conversation
{ | ||
size_t *p = (size_t *)jl_gc_counted_malloc(sz + sizeof(size_t)); | ||
p[0] = sz; | ||
return (void *)(p + 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.
this needs to add 16 bytes, to keep p aligned
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.
does malloc has any alignment guarantee beyond sizeof(void*) ?
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.
yes, on almost all modern platforms, it guarantees 16-byte alignment
edit: if size > 16
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 might as well have this be 16 aligned then. I would think that libraries actually needing such alignment would be defensive about it, but let's not be greedy for 8 bytes (aka the Jameson way :p )
Actually I just come across |
Thanks for the comments. Here is a new attempt. |
it's not portable, although something similar is available on most systems |
There are |
Depend on what's the allocation pattern of cholmod I'm just wondering how much memory we'll save by not storing the same information (size) twice. Edit: and whether it's worth writing a non-portable optimization for it. |
Well it's a non breaking change to go back and use platform dependent functions, so let's merge this first. Most C code that cares about perf wont use malloc for small things anyway. |
Agree. (especially the non-breaking improvement part). |
c63497b
to
7f74c23
Compare
Tests are passing now. Had to update the .travis.yml. @vtjnash would you take a look at the changes to |
lgtm |
Define gc counted allocator functions with libc API
...and use them in CHOLMOD wrappers. This makes the memory consumption from SuiteSparse visible to our GC. Right now SuiteSparse object looks tiny to the GC even though they are huge and in consequence much memory is left allocated when it could be freed.
In particular, I'd like comments on the
gc.c
part of this as I haven't touched that part of the code base before.