Avoid contention when recording atomic accesses

RESOLVED FIXED in Firefox 65

Status

()

defect
RESOLVED FIXED
9 months ago
9 months ago

People

(Reporter: bhackett, Assigned: bhackett)

Tracking

(Blocks 1 bug)

unspecified
mozilla65
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox65 fixed)

Details

Attachments

(5 attachments)

Posted patch patchSplinter Review
When atomic accesses are performed in a recording/replaying process, they are wrapped in a recorded mutex in order to ensure the atomic accesses happen in the same order while replaying that they did while recording.  This is simple but it's also slow: accessing the mutex has a lot of overhead, but more importantly this introduces a lot of artificial contention between threads.  There isn't any need to replay atomic accesses in the exact order they happened while recording; it is sufficient to ensure that accesses on the *same* atomic happen while replaying as while recording.  I.e. conceptually each atomic value wraps a lock around its accesses, but instead of there being a single lock for all values there could be a different lock for each value.

The attached patch picks a middle ground between using a single lock and using a separate lock for every atomic.  A fixed size pool of locks is used, and each atomic value is associated with the same lock throughout its lifetime, using a hash of its pointer address.  I also reworked how atomics are recorded/replayed to avoid using a mutex and its associated overhead.  This results in a pretty dramatic performance improvement on complex pages.
Change the public record/replay API so that callers specify the address of the atomic value (or a nearby address, as long as the same address is always used for the same atomic) being recorded.
Attachment #9020215 - Flags: review?(nfroyd)
Fix users of the atomic access API outside of toolkit/recordreplay.
Attachment #9020220 - Flags: review?(nfroyd)
Fix users of the atomic access API within toolkit/recordreplay.
Attachment #9020222 - Flags: review?(nfroyd)
Core logic to use a pool of locks for atomic accesses, and avoid using system mutexes when recording them.
Attachment #9020224 - Flags: review?(nfroyd)
Comment on attachment 9020215 [details] [diff] [review]
Part 1 - Specify the address of atomic values when recording ordered atomic accesses.

Review of attachment 9020215 [details] [diff] [review]:
-----------------------------------------------------------------

Are you going to collapse these patches in any way so that bisecting continues to work, or are you going to land them as they are?
Attachment #9020215 - Flags: review?(nfroyd) → review+
Attachment #9020220 - Flags: review?(nfroyd) → review+
Attachment #9020222 - Flags: review?(nfroyd) → review+
Attachment #9020224 - Flags: review?(nfroyd) → review+
(In reply to Nathan Froyd [:froydnj] from comment #5)
> Comment on attachment 9020215 [details] [diff] [review]
> Part 1 - Specify the address of atomic values when recording ordered atomic
> accesses.
> 
> Review of attachment 9020215 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Are you going to collapse these patches in any way so that bisecting
> continues to work, or are you going to land them as they are?

When I've been landing these patch series I've landed the patches as they were reviewed, so people looking at the revision history can match the landed code up with the actual changes in the bug.  I haven't really thought about bisection but shouldn't bisection tools be smart enough to either focus on the push log rather than the change log, or just ignore changesets that don't build or are otherwise broken?
(In reply to Brian Hackett (:bhackett) from comment #6)
> (In reply to Nathan Froyd [:froydnj] from comment #5)
> > Are you going to collapse these patches in any way so that bisecting
> > continues to work, or are you going to land them as they are?
> 
> When I've been landing these patch series I've landed the patches as they
> were reviewed, so people looking at the revision history can match the
> landed code up with the actual changes in the bug.  I haven't really thought
> about bisection but shouldn't bisection tools be smart enough to either
> focus on the push log rather than the change log, or just ignore changesets
> that don't build or are otherwise broken?

I am pretty sure that common bisection tools know nothing about the pushlog; my impression is that pushlog is a Mozilla-specific thing?  I don't know what the common solution is to non-building changesets, though.

Anyway, if you've been landing the reviewed things thus far, might as well continue that pattern, rather than squashing.
Pushed by bhackett@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/9a3d3ccfdd50
Part 1 - Specify the address of atomic values when recording ordered atomic accesses, r=froydnj.
https://hg.mozilla.org/integration/mozilla-inbound/rev/c7ed95dcc001
Part 2 - Fix  useUse new atomic access API in Gecko, r=froydnj.
https://hg.mozilla.org/integration/mozilla-inbound/rev/e911b99c9c08
Part 3 - Use new atomic access API in internal record/replay logic, r=froydnj.
https://hg.mozilla.org/integration/mozilla-inbound/rev/b31239e8fbe3
Part 4 - Relax ordering requirements for atomic accesses to be specific to the atomic value itself, r=froydnj.
You need to log in before you can comment on or make changes to this bug.