-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[future] read/write furtex for dict and deque #19
Comments
deque doesn't need multiple readers. most operations on deques are "append" (write lock) and "pop" or "popleft" (write lock). dict so far hasn't really needed multiple readers. x.py is a worst-case scenario for dict; it has seven threads looking up "fib" in the module dict over and over, and "fib" is a small recursive function. really it does very little else. the actual lookup is super-fast, so it doesn't hold the lock for very long, so even in this worst case contention is pretty low. meanwhile, any kind of locking is going to add synchronization overhead. I don't know what % of the overhead of looking up "fib" in the module dict is pure synchronization overhead vs actual contention and waiting. my suspicion is it is primarily the former. Dino said he can do the experiment pretty cheaply because his locks already support multiple readers. until I see some numbers that say "yes multiple reader locks are a win" it's not very high on my priority list. |
We had a small discussion with Anton about that, and I think you had some, too, at the sprint. Implementing a r/w lock so it knows if the current thread is the only one reading so we can safely grab a write lock does not sound as something very easy to achieve. I think I can play and try to prototype a naive approach (ignoring the issue above) to try and see if this gives us anything useful for x.py benchmark. |
dict and collections.deque is one of the few objects that are heavily utilized by multiple threads. Dicts are used for module name spaces. Module dicts are mostly read-only. threadings.Condition and the queue module use deque internally.
It makes sense to implement r/w locking to allow multiple concurrent readers.
The text was updated successfully, but these errors were encountered: