Changeset 205600 in webkit
- Timestamp:
- Sep 8, 2016, 12:56:05 AM (9 years ago)
- Location:
- releases/WebKitGTK/webkit-2.14/Source/bmalloc
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.14/Source/bmalloc/ChangeLog
r205045 r205600 1 2016-08-30 Geoffrey Garen <ggaren@apple.com> 2 3 bmalloc: speed up the lock slow path 4 https://bugs.webkit.org/show_bug.cgi?id=161058 5 6 Unreviewed roll-in - with regression fixed. 7 8 Revert to using yield() instead of swtch() because very low priority 9 background tasks can cause priority inversion and deadlock. In the 10 network process, that happened with com.apple.WebKit.Cache.Storage.serialBackground. 11 12 Still a big speedup on MallocBench. 13 14 * bmalloc.xcodeproj/project.pbxproj: 15 * bmalloc/ScopeExit.h: Added. 16 (bmalloc::ScopeExit::ScopeExit): 17 (bmalloc::ScopeExit::~ScopeExit): 18 (bmalloc::makeScopeExit): 19 * bmalloc/StaticMutex.cpp: 20 (bmalloc::StaticMutex::lockSlowCase): 21 * bmalloc/StaticMutex.h: 22 (bmalloc::StaticMutex::init): 23 1 24 2016-08-26 Geoffrey Garen <ggaren@apple.com> 2 25 -
releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
r205032 r205600 25 25 14895D911A3A319C0006235D /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14895D8F1A3A319C0006235D /* Environment.cpp */; }; 26 26 14895D921A3A319C0006235D /* Environment.h in Headers */ = {isa = PBXBuildFile; fileRef = 14895D901A3A319C0006235D /* Environment.h */; settings = {ATTRIBUTES = (Private, ); }; }; 27 148EFAE81D6B953B008E721E /* ScopeExit.h in Headers */ = {isa = PBXBuildFile; fileRef = 148EFAE61D6B953B008E721E /* ScopeExit.h */; }; 27 28 14C8992B1CC485E70027A057 /* Map.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C8992A1CC485E70027A057 /* Map.h */; settings = {ATTRIBUTES = (Private, ); }; }; 28 29 14C8992D1CC578330027A057 /* LargeRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 14C8992C1CC578330027A057 /* LargeRange.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 111 112 14895D8F1A3A319C0006235D /* Environment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Environment.cpp; path = bmalloc/Environment.cpp; sourceTree = "<group>"; }; 112 113 14895D901A3A319C0006235D /* Environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Environment.h; path = bmalloc/Environment.h; sourceTree = "<group>"; }; 114 148EFAE61D6B953B008E721E /* ScopeExit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScopeExit.h; path = bmalloc/ScopeExit.h; sourceTree = "<group>"; }; 113 115 14B650C518F39F4800751968 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; 114 116 14B650C618F39F4800751968 /* bmalloc.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = bmalloc.xcconfig; sourceTree = "<group>"; }; … … 263 265 144469FD17A61F1F00F9EA1D /* PerThread.h */, 264 266 145F6878179E3A4400D65598 /* Range.h */, 267 148EFAE61D6B953B008E721E /* ScopeExit.h */, 265 268 143CB81A19022BC900B16A45 /* StaticMutex.cpp */, 266 269 143CB81B19022BC900B16A45 /* StaticMutex.h */, … … 317 320 1400274A18F89C2300115C97 /* VMHeap.h in Headers */, 318 321 1400274918F89C1300115C97 /* Heap.h in Headers */, 322 148EFAE81D6B953B008E721E /* ScopeExit.h in Headers */, 319 323 140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */, 320 324 4426E2811C838EE0008EB042 /* Logging.h in Headers */, -
releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc/ScopeExit.h
r205599 r205600 1 1 /* 2 * Copyright (C) 201 4Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #include "StaticMutex.h"27 #include < thread>26 #include <type_traits> 27 #include <utility> 28 28 29 29 namespace bmalloc { 30 30 31 void StaticMutex::lockSlowCase() 31 template<typename ExitFunction> 32 class ScopeExit { 33 public: 34 explicit ScopeExit(ExitFunction&& exitFunction) 35 : m_exitFunction(exitFunction) 36 { 37 } 38 39 ~ScopeExit() 40 { 41 m_exitFunction(); 42 } 43 44 private: 45 ExitFunction m_exitFunction; 46 }; 47 48 template<typename ExitFunction> 49 ScopeExit<ExitFunction> makeScopeExit(ExitFunction&& exitFunction) 32 50 { 33 while (!try_lock()) 34 std::this_thread::yield(); 51 return ScopeExit<ExitFunction>(std::forward<ExitFunction>(exitFunction)); 35 52 } 36 53 37 54 } // namespace bmalloc -
releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc/StaticMutex.cpp
r205022 r205600 24 24 */ 25 25 26 #include "ScopeExit.h" 26 27 #include "StaticMutex.h" 27 28 #include <thread> … … 31 32 void StaticMutex::lockSlowCase() 32 33 { 34 // The longest critical section in bmalloc is much shorter than the 35 // time it takes to make a system call to yield to the OS scheduler. 36 // So, we try again a lot before we yield. 37 static const size_t aLot = 256; 38 39 if (!m_isSpinning.test_and_set()) { 40 auto clear = makeScopeExit([&] { m_isSpinning.clear(); }); 41 42 for (size_t i = 0; i < aLot; ++i) { 43 if (try_lock()) 44 return; 45 } 46 } 47 48 // Avoid spinning pathologically. 33 49 while (!try_lock()) 34 50 std::this_thread::yield(); -
releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc/StaticMutex.h
r205022 r205600 53 53 54 54 std::atomic_flag m_flag; 55 std::atomic_flag m_isSpinning; 55 56 }; 56 57 … … 79 80 { 80 81 m_flag.clear(); 82 m_isSpinning.clear(); 81 83 } 82 84
Note:
See TracChangeset
for help on using the changeset viewer.