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
fiber context update for macOS #4313
fiber context update for macOS #4313
Conversation
Thanks for this. Have you ever seen it return EAGAIN? Under what situation can it happen? This is just advisory so maybe it's not important. I would be concerned about introducing infinite loop. It makes sense we do it after allocating pages because they are not going to be used right away. However there should be a performance cost to this. Also, I wondered is this not the default state, or can we provide the flags to mmap? |
@@ -433,6 +433,12 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) | |||
*count = (*count) >> 1; | |||
} | |||
else { | |||
#if defined(MADV_FREE_REUSE) |
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.
Is MADV_FREE_REUSE
a MacOS specific thing? Because it's different from below (MADV_FREE_REUSABLE
).
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 it s Darwin specific.
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 add a comment to explain this.
There might be tiny performance cost indeed but it's for the system to give hint about proper resident memory accounting. Unfortunately there is no mmap flag for this also the EAGAIN case occurs rarely but sometimes the system gives little extra chance to complete its task, the internal allocator of mac does similarly for example for committing/decommitting pages. |
It's not so much the performance cost, it's more that we now have an infinite loop in the interpreter, where the OS can validly return
What do you think? |
I tried it and it is valid on macOS, but it doesn't seem to be documented in the man page. Weird. Are they actually different? |
I noticed this implementation in Go:
It seems one is used for reporting that it's in use and one is used for reporting it's not in use. Is that correct? |
Yes they are, they complete each other. reusable means "now this chunk can be reused" reuse means "I actually reuse this chunk previously marked by reusable" (note if it was not marked it s no op). |
Another example, webkit Note they both do not appear in the man page and it is poorly documented indeed, it is however grabbing hints and implementing it (eg in custom allocators) that I got to know how. |
IF you believe the loop is necessary, please add it for all instances of Once it's done, we can merge. |
It is only needed for the Mac case I ll comment the code. |
it is more about memory accounting sake. At allocation time, we make clear we re possibly reusing regions marked as reusable. Noted also calls might not necessarily succeed at first so we do only when necessary.
2354e0a
to
c120f34
Compare
Thanks! |
it is more about memory accounting sake. At allocation time,
we make clear we re possibly reusing regions marked as reusable.
Noted also calls might not necessarily succeed at first so we do
only when necessary.