WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
159384
WTF::Lock should be fair eventually
https://bugs.webkit.org/show_bug.cgi?id=159384
Summary
WTF::Lock should be fair eventually
Filip Pizlo
Reported
2016-07-01 21:09:08 PDT
For critical sections that are held for a long time, it makes sense to have a completely fair lock, since the cost of forced context switches is small by comparison to the cost of waiting on a thread that barged into the lock.
Attachments
maybe
(12.55 KB, patch)
2016-07-01 21:09 PDT
,
Filip Pizlo
no flags
Details
Formatted Diff
Diff
OMG it totally works!
(26.30 KB, patch)
2016-07-02 13:42 PDT
,
Filip Pizlo
no flags
Details
Formatted Diff
Diff
the patch
(33.92 KB, patch)
2016-07-02 14:31 PDT
,
Filip Pizlo
no flags
Details
Formatted Diff
Diff
the patch
(35.16 KB, patch)
2016-07-02 14:45 PDT
,
Filip Pizlo
buildbot
: commit-queue-
Details
Formatted Diff
Diff
Archive of layout-test-results from ews113 for mac-yosemite
(1.46 MB, application/zip)
2016-07-02 15:54 PDT
,
Build Bot
no flags
Details
the patch
(35.47 KB, patch)
2016-07-02 16:49 PDT
,
Filip Pizlo
no flags
Details
Formatted Diff
Diff
the patch
(36.12 KB, patch)
2016-07-03 10:50 PDT
,
Filip Pizlo
ggaren
: review+
Details
Formatted Diff
Diff
patch for landing
(37.52 KB, patch)
2016-07-05 12:08 PDT
,
Filip Pizlo
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Filip Pizlo
Comment 1
2016-07-01 21:09:41 PDT
Created
attachment 282637
[details]
maybe I haven't even compiled this yet.
Filip Pizlo
Comment 2
2016-07-02 13:42:46 PDT
Created
attachment 282642
[details]
OMG it totally works!
Filip Pizlo
Comment 3
2016-07-02 14:31:17 PDT
Created
attachment 282643
[details]
the patch
WebKit Commit Bot
Comment 4
2016-07-02 14:33:26 PDT
Attachment 282643
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/ParkingLot.cpp:622: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:659: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:698: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:738: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 4 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Filip Pizlo
Comment 5
2016-07-02 14:45:36 PDT
Created
attachment 282644
[details]
the patch
WebKit Commit Bot
Comment 6
2016-07-02 14:46:10 PDT
Attachment 282644
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/ParkingLot.cpp:622: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:659: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:698: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:738: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 4 in 10 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 7
2016-07-02 15:54:32 PDT
Comment on
attachment 282644
[details]
the patch
Attachment 282644
[details]
did not pass mac-debug-ews (mac): Output:
http://webkit-queues.webkit.org/results/1615273
Number of test failures exceeded the failure limit.
Build Bot
Comment 8
2016-07-02 15:54:36 PDT
Created
attachment 282645
[details]
Archive of layout-test-results from ews113 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-yosemite Platform: Mac OS X 10.10.5
Filip Pizlo
Comment 9
2016-07-02 16:49:54 PDT
Created
attachment 282646
[details]
the patch Turns out I had an assertion exactly backwards.
WebKit Commit Bot
Comment 10
2016-07-02 16:52:22 PDT
Attachment 282646
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/ParkingLot.cpp:622: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:666: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:705: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:745: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 4 in 10 files If any of these errors are false positives, please file a bug against check-webkit-style.
Filip Pizlo
Comment 11
2016-07-03 10:50:21 PDT
Created
attachment 282661
[details]
the patch
WebKit Commit Bot
Comment 12
2016-07-03 10:51:52 PDT
Attachment 282661
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/ParkingLot.cpp:622: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:666: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:705: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:745: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 4 in 10 files If any of these errors are false positives, please file a bug against check-webkit-style.
Geoffrey Garen
Comment 13
2016-07-05 10:36:21 PDT
Comment on
attachment 282661
[details]
the patch View in context:
https://bugs.webkit.org/attachment.cgi?id=282661&action=review
This is pretty cool. Randomness wins again!
> Source/WTF/wtf/Lock.cpp:121 > + return 1;
It's nice that token establishes a separation of concerns between ParkingLot and Lock, but it's also a bummer for readability that we have to be so abstract (0 vs 1) about a concept that has only one use -- to determine if we need to lock or not. One way to solve this is to use an old-school enum inside Lock, which can auto-convert to int: enum LockToken : intptr_t { DoesNotHoldLock, HoldsLock }; Or maybe a class inside Lock: class LockToken { public: LockToken(bool holdsLock) : m_holdsLock(holdsLock) { } operator intptr_t() { return m_holdsLock; } bool holdsLock() { return m_holdsLock; } private: bool m_holdsLock; };
> Source/WTF/wtf/Lock.h:134 > + enum Fairness {
Let's use enum class. The type safety and namespacing are nice.
Filip Pizlo
Comment 14
2016-07-05 11:09:53 PDT
(In reply to
comment #13
)
> Comment on
attachment 282661
[details]
> the patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=282661&action=review
> > This is pretty cool. Randomness wins again! > > > Source/WTF/wtf/Lock.cpp:121 > > + return 1; > > It's nice that token establishes a separation of concerns between ParkingLot > and Lock, but it's also a bummer for readability that we have to be so > abstract (0 vs 1) about a concept that has only one use -- to determine if > we need to lock or not.
You're right, this should be an enum!
> > One way to solve this is to use an old-school enum inside Lock, which can > auto-convert to int: > > enum LockToken : intptr_t { > DoesNotHoldLock, > HoldsLock > };
Or we could use the Fairness enum.
> > Or maybe a class inside Lock: > > class LockToken { > public: > LockToken(bool holdsLock) : m_holdsLock(holdsLock) { } > operator intptr_t() { return m_holdsLock; } > bool holdsLock() { return m_holdsLock; } > > private: > bool m_holdsLock; > }; > > > Source/WTF/wtf/Lock.h:134 > > + enum Fairness { > > Let's use enum class. The type safety and namespacing are nice.
OK.
Filip Pizlo
Comment 15
2016-07-05 11:23:07 PDT
I ended up going with normal enums, not enum classes, because this is not valid: enum class Thing : intptr_t { Foo, Bar } [&] (things) -> intptr_t { return Thing::Foo; // Compiler error, it wants a cast here!! } Also, for the Fairness enum, it felt really awkward to say Fairness::Fair and Fairness::Unfair. I don't know if we have a style rule for this, but I've been using the rule that plain enums are better if prefixing the enum class name would be tautological. It is in this case, since the enums are already encapsulated inside the protected namespace of WTF::LockBase and the names of the members tell you everything you need to know.
Filip Pizlo
Comment 16
2016-07-05 12:08:05 PDT
Created
attachment 282802
[details]
patch for landing
WebKit Commit Bot
Comment 17
2016-07-05 12:10:00 PDT
Attachment 282802
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/ParkingLot.cpp:622: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:666: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:705: Place brace on its own line for function definitions. [whitespace/braces] [4] ERROR: Source/WTF/wtf/ParkingLot.cpp:745: Place brace on its own line for function definitions. [whitespace/braces] [4] Total errors found: 4 in 10 files If any of these errors are false positives, please file a bug against check-webkit-style.
Filip Pizlo
Comment 18
2016-07-18 11:34:54 PDT
Landed in
https://trac.webkit.org/changeset/203350
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