Repository navigation
Conversation
|
It may be wise to make this a configure option also? |
d13747f to
cb33fce
Compare
|
Re: configure option, at a minimum we need a configure test to conditionally enable this code for the supported platform (gcc+x86_64). |
90e158b to
88d422e
Compare
|
@interwq 's comments
|
|
|
||
| if (!prof_active || likely(prof_sample_accum_update(tsd, usize, update, | ||
| &tdata))) | ||
| if (!malloc_option_default_on(&prof_active) || |
There was a problem hiding this comment.
This isn't safe, because there are code paths that require consistency re: prof_active across a series of function invocations, e.g. in irealloc_prof(). Should I just revert this particular change, or is there some other way we can accomplish this safely?
|
12f84b2 to
fa73ac8
Compare
commit f4a0f32 sped up the fast-path substantially, but we still have an init check (slow_path), and a prof / prof_active check. Using dynamic runtime code patching, we can remove all of them. This depends on asm goto in gcc, and static global addresses, so optimize mode is also required. Code is provided for x86_64 only, but the same technique should work on most arches. Note that although we patch the option, currently running threads may still take the old branch for a while until the cache flushes, so this is only an optimization. Testing: In microbenchmarks, this is a 2% cpu improvement. It's so small it is hard to tell in production though. By comparison, sized-deallocations are 10% cpu in a microbenchmark. linux's perf utility was used to view currently executing asm. Used mallctl to flip prof_active on/off, checked that it appeared to be working correctly. Tested building in debug / opt mode, but don't have anything else besides x86_64 to check that the compile options are correct.
|
5.0 is looking big, would prefer to punt until later, possibly a minor release since this doesn't change any APIs. A recent paper on this technique: http://www.cs.indiana.edu/~rrnewton/papers/pldi16-crossmod.pdf May conflict with #501 , since it might remove some of the slow path branches needed to support reentrancy. The config option branches could probably still be removed though |
|
Punting to a later release, per @djwatson's recommendation. |
|
Closing, now that #539 is tracking the hotpatching. |
commit f4a0f32 sped up the fast-path substantially, but we still have
an init check (slow_path), and a prof / prof_active check. Using
dynamic runtime code patching, we can remove all of them.
This depends on asm goto in gcc, and static global addresses, so optimize
mode is also required. Code is provided for x86_64 only, but
the same technique should work on most arches.
Note that although we patch the option, currently running threads
may still take the old branch for a while until the cache flushes,
so this is only an optimization.
Testing:
In microbenchmarks, this is a 2% cpu improvement. It's so small it is hard
to tell in production though. By comparison, sized-deallocations are 10% cpu
in a microbenchmark.
linux's perf utility was used to view currently executing asm. Used mallctl
to flip prof_active on/off, checked that it appeared to be working correctly.
Tested building in debug / opt mode, but don't have anything else besides
x86_64 to check that the compile options are correct.