-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Add a benchmark/example for numexpr usage under free-threading conditions #508
base: master
Are you sure you want to change the base?
Conversation
@@ -1009,5 +1005,5 @@ def re_evaluate(local_dict: Optional[Dict] = None, | |||
argnames = _numexpr_last.l['argnames'] | |||
args = getArguments(argnames, local_dict, global_dict, _frame_depth=_frame_depth) | |||
kwargs = _numexpr_last.l['kwargs'] | |||
with evaluate_lock: | |||
return compiled_ex(*args, **kwargs) | |||
# with evaluate_lock: |
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.
@FrancescAlted, it seems that this lock is a performance bottleneck when multiple threads are ran in parallel, is it necessary?
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.
With the lock:
Benchmarking Expression 1:
NumPy time (threaded over 32 chunks with 16 threads): 3.276298 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 9.975059 seconds
numexpr speedup: 0.33x
----------------------------------------
Benchmarking Expression 2:
NumPy time (threaded over 32 chunks with 16 threads): 18.981946 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 50.327974 seconds
numexpr speedup: 0.38x
----------------------------------------
Benchmarking Expression 3:
NumPy time (threaded over 32 chunks with 16 threads): 20.414158 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 70.900648 seconds
numexpr speedup: 0.29x
----------------------------------------
Benchmarking Expression 4:
NumPy time (threaded over 32 chunks with 16 threads): 38.012808 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 160.476216 seconds
numexpr speedup: 0.24x
----------------------------------------
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.
Without locking:
Benchmarking Expression 1:
NumPy time (threaded over 32 chunks with 16 threads): 3.415349 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 2.618876 seconds
numexpr speedup: 1.30x
----------------------------------------
Benchmarking Expression 2:
NumPy time (threaded over 32 chunks with 16 threads): 19.005238 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 12.611407 seconds
numexpr speedup: 1.51x
----------------------------------------
Benchmarking Expression 3:
NumPy time (threaded over 32 chunks with 16 threads): 20.555149 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 17.690749 seconds
numexpr speedup: 1.16x
----------------------------------------
Benchmarking Expression 4:
NumPy time (threaded over 32 chunks with 16 threads): 38.338372 seconds
numexpr time (threaded with re_evaluate over 32 chunks with 16 threads): 35.074684 seconds
numexpr speedup: 1.09x
----------------------------------------
Fixes #503