-
Notifications
You must be signed in to change notification settings - Fork 45
Thread local tag cache #306
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
Conversation
`findTag` spends ~90% of its time contending on the lock, this lowers that significantly, taking findTag from 3.9% of walltime to 0.8%. There will be a small amount of Tag* leakage until the threads are destroyed at which point the thread local caches will be automatically cleaned up. Signed-off-by: Drew Lewis <cannada@google.com>
Signed-off-by: Drew Lewis <cannada@google.com>
This cuts a full run from 8 hrs to 7.5 hrs. |
I wrote most of this PR in a code base where |
I sort of get the idea of what this is doing, but I don't completely understand all of the complications with "clear_counts". My concern is that I get stuck with fixing the non-trivial thread related bugs that show up after this goes in the code. It needs a LOT of work to look like the other code in OpenSTA, which is another prerequisite. I can't even begin to list them there are so many, so I suggest you read read doc/CodingGuidelines.txt and look around and try to match the existing code. |
Signed-off-by: Drew Lewis <cannada@google.com>
Signed-off-by: Drew Lewis <cannada@google.com>
@jjcherry56, I believe things should be formatted closer to what is in the docs now.
When elements are removed from the interned set via I agree, the design of Search and especially the fact that TagHash and TagEqual aren't stateless makes reasoning about thread safety difficult, I would like your assistance to ensure this is safe. The performance benefits are fairly large ~6% by tspyrou's calculation and 3%+ for my small test so I believe it is worth the effort. If you would be kind enough to point me towards instructions on how to do so, I'll test these changes in OR with tsan enabled to gain some confidence that there aren't lurking issues. FWIW lock contention in search is a significant amount of total time in all the multithread runs we conduct, if you have less creative ways to reduce that contention that would be awesome. |
I think the idea of using a cache in front of the lock is a good one, |
Replaced by #316 |
Add a thread local cache in front of findTag to reduce lock contention.
findTag
spends ~90% of its time contending on the lock. This pr lowersthat significantly, taking findTag from 3.9% of wall time to 0.8%.
There will be a small amount of Tag* leakage until the threads are
destroyed at which point the thread local caches will be automatically
cleaned up.