Bug 161058

Summary: bmalloc: speed up the lock slow path
Product: WebKit Reporter: Geoffrey Garen <ggaren>
Component: New BugsAssignee: Geoffrey Garen <ggaren>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, barraclough, commit-queue, fpizlo, kling, rniwa, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch fpizlo: review+

Geoffrey Garen
Reported 2016-08-22 14:33:13 PDT
bmalloc: speed up the lock slow path
Attachments
Patch (16.99 KB, patch)
2016-08-22 15:19 PDT, Geoffrey Garen
fpizlo: review+
Geoffrey Garen
Comment 1 2016-08-22 15:19:55 PDT
WebKit Commit Bot
Comment 2 2016-08-22 15:21:04 PDT
Attachment 286629 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/StaticMutex.cpp:26: Found other header before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] ERROR: Source/bmalloc/bmalloc/StaticMutex.cpp:40: More than one command on the same line [whitespace/newline] [4] Total errors found: 2 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
Filip Pizlo
Comment 3 2016-08-22 15:23:19 PDT
Comment on attachment 286629 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=286629&action=review > Source/bmalloc/ChangeLog:26 > + To correct these problems, this patch adds a little bit of spinning to > + the bmalloc lock slow path. Nice. > Source/bmalloc/bmalloc/StaticMutex.cpp:40 > + auto clear = makeScopeExit([&] { m_isSpinning.clear(); }); LOL. I can't make up my mind if this is awesome or confusing. > Source/bmalloc/bmalloc/ThreadSwitch.h:38 > + swtch(); What is this?
Geoffrey Garen
Comment 4 2016-08-22 16:12:05 PDT
> > Source/bmalloc/bmalloc/StaticMutex.cpp:40 > > + auto clear = makeScopeExit([&] { m_isSpinning.clear(); }); > > LOL. I can't make up my mind if this is awesome or confusing. I kinda like it -- similar to the defer keyword in Go and Swift. The other option I considered was a "TestAndSetScope" class, which would clear() in its destructor if it had set in its constructor. > > Source/bmalloc/bmalloc/ThreadSwitch.h:38 > > + swtch(); > > What is this? Documented here: https://www.gnu.org/software/hurd/gnumach-doc/Hand_002dOff-Scheduling.html. My reading of the implementation is that it just runs the "find another thread to run" algorithm, without changing your priority or power management or anything.
Geoffrey Garen
Comment 5 2016-08-22 16:19:50 PDT
Yusuke Suzuki
Comment 6 2016-08-22 17:44:58 PDT
Ryosuke Niwa
Comment 7 2016-08-23 23:03:44 PDT
This appears to be ~6% progression on Dromaeo DOM Core bench on MacBookAirs.
Geoffrey Garen
Comment 8 2016-08-24 10:54:26 PDT
On Speedometer, I also see a ~4% progression on MacBook Air and a ~2% progression on MacBook Pro.
Geoffrey Garen
Comment 9 2016-08-25 16:48:44 PDT
I can't seem to reproduce a Dromaeo DOM Core or Speedometer speedup locally on my MacBook Air. (I see a fraction of a % speedup or no change. I didn't compute a confident interval.)
Gavin Barraclough
Comment 10 2016-08-26 10:05:18 PDT
Geoffrey Garen
Comment 11 2016-08-30 17:17:40 PDT
Note You need to log in before you can comment on or make changes to this bug.