Skip to content

Refactor arena synchronization - #621

Closed
jasone wants to merge 6 commits into
jemalloc:devfrom
jasone:atomic
Closed

jasone wants to merge 6 commits into
jemalloc:devfrom
jasone:atomic

Conversation

@jasone

@jasone jasone commented Feb 13, 2017

Copy link
Copy Markdown
Member

This series of changes refactors out arena->lock, through a combination of atomic operations (especially for stats) and field-specific independent mutexes.

This relates to #466.

@jasone jasone added this to the 5.0.0 milestone Feb 13, 2017
@jasone jasone self-assigned this Feb 13, 2017
@jasone

jasone commented Feb 13, 2017

Copy link
Copy Markdown
Member Author

This is going to need some rework, because it uses 64-bit atomic ops, and we don't currently have those on 32-bit platforms.

@jasone jasone mentioned this pull request Feb 13, 2017
do {
a0 = atomic_read_u64(&arena->prof_accumbytes);
a1 = a0 + accumbytes;
overflow = (a1 >= prof_interval);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible for accumbytes to be huge? If so this may overflow uint64, in which case the overflow calculation needs to be adjusted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

prof_interval can be no larger than 2^63, so I don't think arena->prof_accumbytes can overflow in practice.

a1 = a0 + accumbytes;
overflow = (a1 >= prof_interval);
if (overflow) {
a1 %= prof_interval;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This implies that we may get 1 sample for multiple of prof_interval bytes. Probably worth mentioning in a comment?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do.

@jasone

jasone commented Feb 14, 2017

Copy link
Copy Markdown
Member Author

I'm going to close this pull request and create a new one once I have a workable strategy for 64-bit stats counters.

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.

2 participants