Optimize memory poisoning (maybe?)
Categories
(Core :: Memory Allocator, enhancement)
Tracking
()
People
(Reporter: gsvelto, Unassigned)
References
Details
This is an idea I had when discussing the performance impact of poisoning. Our poison code is just a memset() so we're bound by whatever implementation we got underneath.
A couple of years ago I stumbled upon this excellent post that described in detail the memset implementation of the NT kernel, complete with performance data. I wonder if the same implementation is used in userspace on Windows and I wonder if that kind of implementation might be faster than whatever the macOS libc and glibc offer.
If poisoning has a measurable impact on our performance this might be worth pursuing given we use it in other places too (like the JIT).
Reporter | ||
Comment 1•2 years ago
|
||
Note that having our implementation also has the advantage of consistent performance across all platforms.
Comment 2•2 years ago
|
||
Also note that we already have guarantees about the alignment of both the pointer and length, which would allow to skip some of the checks memset would normally do.
Comment 3•2 years ago
|
||
Related, Bas tried an experiment with non-temporal writes for our poisoning (writes that advise the memory system that we won't bother accessing the data soon so don't bother caching it). He found that it made no difference. But this does sound promising.
Comment 4•2 years ago
|
||
I wanted to see how much potential improvement there could be for making these changes. So I ran a test with poisoning disabled
because this would give us an upper bound. Of course this is not something that we could achieve by optimising poisoning, it's just "how much does poisoning cost?" I also didn't include things like 0 initialising and other memset()
. But they're also a factor. IMO the way to interpret these results is by looking at which tests don't show a difference and saying "Optimising poisoning won't change them". The others, it's still maybe.
It doesn't make a difference for speedometer, but does for page loads and visual metrics. Many by ~5% some >20%.
This reminds me. We could consider making poisoning probabilistic for larger memory cells (keep it certain for small ones on the assumption that they disturb things less). But I'd like to do Bug 1801255 first.
Description
•