WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
60396
Add RAII-style DenormalDisabler class to disable denormals which hurt audio performance
https://bugs.webkit.org/show_bug.cgi?id=60396
Summary
Add RAII-style DenormalDisabler class to disable denormals which hurt audio p...
Chris Rogers
Reported
2011-05-06 12:42:34 PDT
Add macros to disable denormals on x86 for audio-intensive algorithms
Attachments
Patch
(1.95 KB, patch)
2011-05-06 12:45 PDT
,
Chris Rogers
no flags
Details
Formatted Diff
Diff
Patch
(8.77 KB, patch)
2011-05-09 12:55 PDT
,
Chris Rogers
kbr
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Chris Rogers
Comment 1
2011-05-06 12:45:55 PDT
Created
attachment 92627
[details]
Patch
Alexey Proskuryakov
Comment 2
2011-05-06 17:35:09 PDT
Can this be a RIAA-style class instead of a pair of macros? This class could disable denormals in constructor, and enable them back in destructor, making sure that we don't accidentally leak the state by taking an unusual code path with an early return.
Chris Rogers
Comment 3
2011-05-06 18:09:28 PDT
Sure, I can probably whip something up like that. Just curious, what is RIAA?
Eric Seidel (no email)
Comment 4
2011-05-08 12:54:18 PDT
http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
Chris Rogers
Comment 5
2011-05-09 12:55:11 PDT
Created
attachment 92834
[details]
Patch
Chris Rogers
Comment 6
2011-05-09 12:57:43 PDT
Latest patch turns this into an RIAA-style class.
Eric Seidel (no email)
Comment 7
2011-05-09 13:23:06 PDT
Comment on
attachment 92834
[details]
Patch Looks nice. Need someone who actually knows about this stuff to comment though.
Eric Seidel (no email)
Comment 8
2011-05-09 13:23:47 PDT
CCing folks who might know something about denormal disabiling.
Oliver Hunt
Comment 9
2011-05-09 13:33:35 PDT
In terms of actual data behaviour what does this do? If I load a denormalised value into an xmm register what happens?
Chris Rogers
Comment 10
2011-05-09 14:24:29 PDT
Oliver, I don't think a simple load will be any different. Setting the denormal mask tells the processor to ignore any exceptions which occur due to any floating-point math which is dealing with denormals. Not handling the exception causes a tiny amount of precision loss, which is acceptable for audio processing. The performance benefit is very large because once these denormals get into a stateful audio processing algorithms they tend to stick around (in filter state, decaying delay lines, parameter slewing/de-glitching, etc.). They can cause a very large number of exceptions to occur, causing enormous slowdown. For all AudioUnits we used to disable them -- here's an old copy of an audio SDK file with this type of disabling (near the top of the file):
http://www.google.com/codesearch/p?hl=en#9WNLlqRP2nE/trunk/PublicUtility/AUPublic/AUBase/AUBase.cpp&q=AUPublic&sa=N&cd=2&ct=rc
Kenneth Russell
Comment 11
2011-05-09 14:49:21 PDT
I think Alexey meant RAII, not RIAA. Very different concepts. :)
Kenneth Russell
Comment 12
2011-05-09 14:59:19 PDT
Comment on
attachment 92834
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=92834&action=review
Couple of minor comments; feel free to fix upon landing.
> Source/WebCore/ChangeLog:5 > + Add RIAA-style DenormalDisabler class to disable denormals which hurt audio performance.
RIAA -> RAII
> Source/WebCore/platform/audio/DenormalDisabler.h:50 > + asm volatile("stmxcsr %0" : "=m" (*&result));
It looks like the *& isn't needed here or on the ldmxcsr; see
http://gcc.gnu.org/bugzilla/attachment.cgi?id=11062
.
Chris Rogers
Comment 13
2011-05-09 16:02:16 PDT
Committed
r86099
: <
http://trac.webkit.org/changeset/86099
>
Sam Weinig
Comment 14
2011-05-09 16:14:10 PDT
(In reply to
comment #10
)
> Oliver, I don't think a simple load will be any different. Setting the denormal mask tells the processor to ignore any exceptions which occur due to any floating-point math which is dealing with denormals. Not handling the exception causes a tiny amount of precision loss, which is acceptable for audio processing. The performance benefit is very large because once these denormals get into a stateful audio processing algorithms they tend to stick around (in filter state, decaying delay lines, parameter slewing/de-glitching, etc.). They can cause a very large number of exceptions to occur, causing enormous slowdown. > > For all AudioUnits we used to disable them -- here's an old copy of an audio SDK file with this type of disabling (near the top of the file): >
http://www.google.com/codesearch/p?hl=en#9WNLlqRP2nE/trunk/PublicUtility/AUPublic/AUBase/AUBase.cpp&q=AUPublic&sa=N&cd=2&ct=rc
Can JavaScript run in the scope this is activated for? If so, can the change in precision show up there?
Chris Rogers
Comment 15
2011-05-09 16:41:48 PDT
Hi Sam, no this will only run in audio-specific threads. It's per-thread state and will not affect the main JS thread or any worker threads.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug