Without this patch, the memory manager would call mprotect on every memory region it ever allocated whenever it wanted to finalize memory (i.e. not just the ones it just allocated). This caused terrible performance problems for long running memory managers. In one particular compile heavy julia benchmark, we were spending 50% of time in mprotect if running under MCJIT. Fix this by splitting
allocated memory blocks into those on which memory permissions have been set and those on which
they haven't and only running mprotect on the latter.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/ExecutionEngine/SectionMemoryManager.cpp | ||
---|---|---|
169 | Thanks! I guess we also need to release the FreeMem blocks in here then. |
lib/ExecutionEngine/SectionMemoryManager.cpp | ||
---|---|---|
169 | Nope. Be careful with this. FreeMem appears to point inside regions tracked by AllocatedMem |
lib/ExecutionEngine/SectionMemoryManager.cpp | ||
---|---|---|
169 | I see, thanks! |
Addresses review comments. @reames let me know if you agree with the wording of the explanatory
comment.
LGTM
lib/ExecutionEngine/SectionMemoryManager.cpp | ||
---|---|---|
143 | very minor: I'd put the clear immediately after each append. |
Thanks for the quick review. Also, while looking at this again, I noticed, we're setting RX permissions on RO memory. Does that sound right? Seems like that memory should be executable? Isn't that the whole point of splitting this?
I assume you meant that we are applying execute permissions to the read
only memory and probably shouldn't be? If so, I tend to agree.
However, I'd have to study the code much more carefully to understand
the implications. There may be an issue with the relocations or something.
Philip
Comment explaining purpose?