Repository navigation
Use trylock in tcache_flush when possible - #800
Merged
Merged
Conversation
interwq
commented
Apr 25, 2017
| void *ptr = *(tbin->avail - 1 - i); | ||
| assert(ptr != NULL); | ||
| extent = iealloc(tsd_tsdn(tsd), ptr); | ||
| extent = item_extent[i]; |
Contributor
Author
There was a problem hiding this comment.
This was fixed separately in #799. Will rebase past that before landing.
jasone
approved these changes
Apr 25, 2017
| } | ||
|
|
||
| bool merged_stats = false; | ||
| unsigned nflushed = 0, nskipped = 0; |
Member
There was a problem hiding this comment.
Style nit: For declarations incorporating initialization, only declare one variable per statement.
| malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock); | ||
| } | ||
| if (must_flush || | ||
| !malloc_mutex_trylock(tsd_tsdn(tsd), &bin->lock)) { |
Member
There was a problem hiding this comment.
Subtle logic here. Add a malloc_mutex_assert_owner() to make it obvious that the mutex is owned inside the block?
interwq
force-pushed
the
tcache_lock
branch
2 times, most recently
from
April 26, 2017 00:09
f9c11d9 to
9fc8e20
Compare
During tcache gc, use tcache_bin_try_flush_small / _large so that we can skip items with their bins locked already.
Only do must_flush if try_flush didn't manage to free anything.
Contributor
Author
|
Only style changes were made. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a production workload,
free -> je_tcache_bin_flush_small -> mutex_lockandtcache_event_hard -> tcache_bin_flush_small -> mutex_lockpaths are ranked 2nd and 3rd hottest among all mutex related paths. This change tries to use trylock to make it non-blocking whenever possible, similar to what we did for decay_lock.