SRWLOCK srwlock = SRWLOCK_INIT;
constexpr size_t rounds = 10000000;
DWORD start = timeGetTime();
for (size_t i = 0; i < rounds; ++i) {
AcquireSRWLockExclusive(&srwlock);
ReleaseSRWLockExclusive(&srwlock);
}
DWORD end = timeGetTime();
DWORD startshared = timeGetTime();
for (size_t i = 0; i < rounds; ++i) {
AcquireSRWLockShared(&srwlock);
ReleaseSRWLockShared(&srwlock);
}
DWORD endshared = timeGetTime();
printf("Exclusive: %d ms\n", end - start);
printf("Shared: %d ms\n", endshared - startshared);
>Sandbox.exe
Exclusive: 138 ms
Shared: 163 ms
>Sandbox.exe
Exclusive: 139 ms
Shared: 163 ms
>Sandbox.exe
Exclusive: 139 ms
Shared: 163 ms
>Sandbox.exe
Exclusive: 138 ms
Shared: 163 ms
>Sandbox.exe
Exclusive: 139 ms
Shared: 162 ms
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAK7A45VgB4Gaph648aQQP2b7qw3E%2BuDRB%2BC%2BhzoLX29M-w0%3D-Q%40mail.gmail.com.
From what I can tell, these uses can just use a regular lock (or existing locks) as the Write Lock is acquired only for the purpose of synchronizing shutdown in both the TaskService and IncomingTaskQueue.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAK7A45U7o7OKzruZkQ0icb_6aL4opj%2BQQ7XX9XM8mbXX3-izNA%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/23206110-ec04-4341-828a-efd55bd2ae32%40chromium.org.
We're keeping base::Lock (which on Windows uses SRWLock underneath with AcquireSRWLockExclusive and ReleaseSRWLockExclusive).ReadWriteLock just exposes an additional AcquireSRWLockShared and ReleaseSRWLockShared, which we likely don't really need in base.
base::AutoLock tasks_in_flight_auto_lock(tasks_in_flight_lock_);
while (tasks_in_flight_ > 0)
no_tasks_in_flight_cv_.Wait();
return true;
base::subtle::AutoWriteLock task_lock(task_lock_);
return true;
The proposal is to remove base::subtle::ReadWriteLock, introduced just over a year ago with only two users in that timespan, both of which could have used something else. Both cases also deal with the write mode only at shutdown of the componentThere are two main motivations for the removal:
- Only two components (now one, and soon zero) have used this lock since the lock's introduction over a year ago, which runs afoul of the wide applicability requirement for base.
- Using this lock correctly can be non-trivial and the lock has perf implications on Windows at least. It's rightfully in base::subtle.
After going through a migration for TaskService, the code's intention is now more obvious
I guess I still don't understand this "perf implication" bit. Isn't the replacement worse?
Maybe more obvious, but less scalable.
However making PostTask block for upwards of 80ms because of contention is unacceptable. So we'll still need some equivalent of RWLock, and if we reimplement it using pure locks (or lock + cv) instead of the existing platform primitive it'll be slower (and that's for every single PostTask for every single message loop). So why would we want to do that?
Actually... I recently requested that we *add* a use of that lock. We recently hit a pretty nasty bug (crbug.com/754213) where we ended up with multiple threads all trying to acquire the PartitionAlloc spin lock. It was a classic priority inversion issue with the net result that Chrome consumed all CPU time and made zero progress. The bug was made more serious by the fact that two of the threads were real-time priority audio threads, and the machines only having two cores. Nasty. Although, the context switch graphs from the ETW trace looked pretty amazing.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/ed6524f0-9cf8-44bd-a7f6-b294dfef7502%40chromium.org.