Closed
Bug 944707
Opened 11 years ago
Closed 11 years ago
Stop locking when getting the preferred samplerate from the AudioStream
Categories
(Core :: Web Audio, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla29
People
(Reporter: padenot, Assigned: padenot)
References
Details
Attachments
(1 file, 4 obsolete files)
(deleted),
patch
|
kinetik
:
review+
|
Details | Diff | Splinter Review |
This function is super high in the profile because there is a high contention on the lock. Best to remove it.
Assignee | ||
Comment 1•11 years ago
|
||
Attachment #8340392 -
Flags: review?(kinetik)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → paul
Assignee | ||
Comment 2•11 years ago
|
||
oops, forgot to rebase over your de-virtualization.
Attachment #8340397 -
Flags: review?(kinetik)
Assignee | ||
Updated•11 years ago
|
Attachment #8340392 -
Attachment is obsolete: true
Attachment #8340392 -
Flags: review?(kinetik)
Assignee | ||
Updated•11 years ago
|
Attachment #8340397 -
Attachment is obsolete: true
Attachment #8340397 -
Flags: review?(kinetik)
Comment 4•11 years ago
|
||
Comment on attachment 8340450 [details] [diff] [review]
Stop locking when getting the preferred samplerate from the AudioStream. r=
Review of attachment 8340450 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/AudioStream.h
@@ +382,5 @@
> static cubeb* sCubebContext;
>
> // Prefered samplerate, in Hz (characteristic of the
> // hardware/mixer/platform/API used).
> static uint32_t sPreferredSampleRate;
Move this above the mutex comment since it no longer applies.
Attachment #8340450 -
Flags: review?(kinetik) → review+
Comment 5•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Comment 7•11 years ago
|
||
I'm going to back this out for now, reopen the bug, and we'll fix it a different way here.
https://hg.mozilla.org/integration/mozilla-inbound/rev/66b206715056
Sorry for missing this in the review. :-/
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: [leave open]
Comment 8•11 years ago
|
||
Comment 9•11 years ago
|
||
So, backing up a step, why are we calling PreferredSampleRate() so often that it matters how fast it is?
Looks like the only two callers are:
- in the constructor for WebAudio's AudioContext, which shouldn't be particularly performance critical
- in MediaStreamGraphImpl::RunThread, inside the processing loop, via IdealAudioRate(), which is probably where the problem stems from
Does the MSG expect the ideal rate to change? If not, we can hoist the call to IdealRate() out of the loop. If it does, we can teach the IdealRate() implementation that the result from PreferredSampleRate() won't change and therefore is safe to cache.
Whiteboard: [leave open]
Comment 10•11 years ago
|
||
Aside from that question, we could try something like this. Store the value in an Atomic, and only take the lock when necessary to initialize the value.
Attachment #8340450 -
Attachment is obsolete: true
Attachment #8344466 -
Flags: review?(paul)
Comment 11•11 years ago
|
||
FWIW, I don't know if this patch will help, since an atomic shouldn't be much cheaper than an uncontended lock on platforms with decent locks.
Assignee | ||
Comment 12•11 years ago
|
||
Maybe this is better?
Attachment #8345422 -
Flags: review?(kinetik)
Updated•11 years ago
|
Attachment #8344466 -
Attachment is obsolete: true
Attachment #8344466 -
Flags: review?(paul)
Comment 13•11 years ago
|
||
Comment on attachment 8345422 [details] [diff] [review]
patch
Looks good.
- // Get the preferred samplerate for this platform, or fallback to something
"sample rate"
+ // Queries the samplerate the hardware/mixer runs at, and stores it.
ditto
+ // Get the aformentionned sample rate. Does not lock.
aforementioned
Attachment #8345422 -
Flags: review?(kinetik) → review+
Assignee | ||
Comment 14•11 years ago
|
||
Assignee | ||
Comment 15•11 years ago
|
||
Backed out for crashes.
https://tbpl.mozilla.org/?tree=Mozilla-Inbound&rev=63ae0ef30e3f
Assignee | ||
Comment 16•11 years ago
|
||
Relanded with the obvious error fixed. (|| instead of && and use the unlocked version of GetCubebContext)
https://hg.mozilla.org/integration/mozilla-inbound/rev/bc103864507b
Updated•11 years ago
|
Priority: -- → P1
Status: REOPENED → RESOLVED
Closed: 11 years ago → 11 years ago
Resolution: --- → FIXED
Target Milestone: mozilla28 → mozilla29
You need to log in
before you can comment on or make changes to this bug.
Description
•