-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-125996: fix thread safety of ordered dict #133734
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please also provide some timing measurements for basic operations?
e87cd54 to
473cfa0
Compare
I added some benchmark for get/set operation to ftscaling and benchmarked it: index 1a59e25189d..20f15200051 100644
--- a/Tools/ftscalingbench/ftscalingbench.py
+++ b/Tools/ftscalingbench/ftscalingbench.py
@@ -28,6 +28,7 @@
import threading
import time
from operator import methodcaller
+from collections import OrderedDict
# The iterations in individual benchmarks are scaled by this factor.
WORK_SCALE = 100
@@ -43,6 +44,19 @@ def register_benchmark(func):
ALL_BENCHMARKS[func.__name__] = func
return func
+@register_benchmark
+def odict_get():
+ tab = OrderedDict((i, i) for i in range(100))
+ for i in range(1000 * WORK_SCALE):
+ tab.get(i % 100)
+
+@register_benchmark
+def odict_set():
+ tab = OrderedDict((i, i) for i in range(100))
+ for i in range(1000 * WORK_SCALE):
+ tab[i % 100] = i
+
+
@register_benchmark
def object_cfunction():
accu = 0
Results: ❯ ./python.exe Tools/ftscalingbench/ftscalingbench.py odict_get odict_set
Running benchmarks with 10 threads
odict_get 4.7x faster
odict_set 4.4x faster
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Sam Gross <[email protected]>
|
Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @kumaraditya303, I could not cleanly backport this to |
|
GH-140053 is a backport of this pull request to the 3.14 branch. |
pythonGH-133734) (cherry picked from commit 6481539) Co-authored-by: Kumar Aditya <[email protected]>
|
Uh oh!
There was an error while loading. Please reload this page.