Skip to content

Lookup extent once per time during tcache_flush_small / _large. - #729

Merged
interwq merged 1 commit into
jemalloc:devfrom
interwq:tcache_flush
Mar 28, 2017
Merged

interwq merged 1 commit into
jemalloc:devfrom
interwq:tcache_flush

Conversation

@interwq

@interwq interwq commented Mar 28, 2017

Copy link
Copy Markdown
Contributor

Caching the extents on stack to avoid redundant looking up overhead.

This resolves #598.

@interwq
interwq force-pushed the tcache_flush branch 2 times, most recently from 5b862c8 to 20ca4db Compare March 28, 2017 00:28
Comment thread src/tcache.c Outdated
assert(arena != NULL);
for (nflush = tbin->ncached - rem; nflush > 0; nflush = ndeferred) {
unsigned nflush = tbin->ncached - rem;
extent_t *item_extent[nflush];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSVC still doesn't like variable-length arrays. Will fix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach you took to resolve this looks fine, but for future reference note that the VARIABLE_ARRAY() macro is an alternative.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I was looking for it and couldn't find it. Thanks for the pointer!

@jasone jasone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment thread src/tcache.c Outdated
* handled in a future pass.
*/
*(tbin->avail - 1 - ndeferred) = ptr;
item_extent[ndeferred] = item_extent[i];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write the right-hand side as just extent (here and in tcache_bin_flush_large())?

Comment thread src/tcache.c Outdated
extent_t *item_extent[TCACHE_NSLOTS_SMALL_MAX];
/* Look up extent once per item. */
for (unsigned i = 0 ; i < nflush; i++) {
item_extent[i] = iealloc(tsd_tsdn(tsd), *(tbin->avail - i - 1));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for consistency, write *(tbin->avail - 1 - i) here (and in tcache_bin_flush_large()) for consistency with the other sites that do similar math.

@interwq

interwq commented Mar 28, 2017

Copy link
Copy Markdown
Contributor Author

Will address feedback and update again before pushing.

Caching the extents on stack to avoid redundant looking up overhead.
@interwq
interwq merged commit d4e98bc into jemalloc:dev Mar 28, 2017
@interwq
interwq deleted the tcache_flush branch March 28, 2017 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider memoizing iealloc() results in tcache_bin_flush_small() / _large()

2 participants