Visitar URL original
dict: Add dk_log2_index_bytes by methane · Pull Request #31439 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221223152042/https://github.com/python/cpython/pull/31439
Skip to content
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

dict: Add dk_log2_index_bytes #31439

Merged
merged 2 commits into from Feb 22, 2022
Merged

dict: Add dk_log2_index_bytes #31439

merged 2 commits into from Feb 22, 2022

Conversation

methane
Copy link
Member

@methane methane commented Feb 20, 2022

No description provided.

@methane
Copy link
Member Author

methane commented Feb 20, 2022

Microbench

code: https://gist.github.com/methane/9d2a35a519d89e657454f278e49fd4ae

Faster (6):
- dict[str, n=1000]: 22.3 ns +- 0.5 ns -> 19.9 ns +- 0.8 ns: 1.12x faster
- dict[int, n=10]: 16.4 ns +- 0.6 ns -> 15.3 ns +- 0.4 ns: 1.07x faster
- dict[int, n=100000]: 27.4 ns +- 0.3 ns -> 26.0 ns +- 0.1 ns: 1.05x faster
- dict[str, n=100000]: 23.2 ns +- 0.9 ns -> 22.1 ns +- 2.3 ns: 1.05x faster
- dict[str, n=10]: 20.1 ns +- 0.6 ns -> 19.5 ns +- 1.4 ns: 1.03x faster
- dict[int, n=1000]: 26.5 ns +- 0.3 ns -> 25.9 ns +- 1.2 ns: 1.02x faster

Geometric mean: 1.06x faster

pyperformance

$ cpython/python -m pyperf compare_to main-opt.json log2bytes-opt.json -G --min-speed=1
Slower (3):
- scimark_fft: 356 ms +- 2 ms -> 368 ms +- 4 ms: 1.03x slower
- scimark_sparse_mat_mult: 5.12 ms +- 0.06 ms -> 5.23 ms +- 0.06 ms: 1.02x slower
- fannkuch: 425 ms +- 4 ms -> 430 ms +- 2 ms: 1.01x slower

Faster (22):
- nbody: 108 ms +- 2 ms -> 102 ms +- 1 ms: 1.07x faster
- logging_silent: 123 ns +- 2 ns -> 115 ns +- 1 ns: 1.07x faster
- pickle_list: 4.92 us +- 0.06 us -> 4.70 us +- 0.03 us: 1.05x faster
- unpickle: 15.1 us +- 0.2 us -> 14.6 us +- 0.2 us: 1.04x faster
- unpack_sequence: 55.5 ns +- 0.7 ns -> 53.5 ns +- 0.8 ns: 1.04x faster
- pickle_dict: 29.6 us +- 0.1 us -> 28.5 us +- 0.1 us: 1.04x faster
- pickle: 11.2 us +- 0.7 us -> 10.8 us +- 0.1 us: 1.04x faster
- float: 89.4 ms +- 1.2 ms -> 86.3 ms +- 1.1 ms: 1.04x faster
- go: 163 ms +- 1 ms -> 157 ms +- 1 ms: 1.03x faster
- pyflate: 501 ms +- 3 ms -> 487 ms +- 3 ms: 1.03x faster
- regex_dna: 240 ms +- 2 ms -> 233 ms +- 1 ms: 1.03x faster
- pathlib: 22.8 ms +- 0.6 ms -> 22.3 ms +- 0.3 ms: 1.02x faster
- richards: 54.7 ms +- 1.1 ms -> 53.5 ms +- 1.0 ms: 1.02x faster
- chaos: 80.2 ms +- 0.6 ms -> 78.7 ms +- 0.9 ms: 1.02x faster
- chameleon: 7.76 ms +- 0.06 ms -> 7.63 ms +- 0.14 ms: 1.02x faster
- regex_effbot: 3.52 ms +- 0.05 ms -> 3.47 ms +- 0.03 ms: 1.01x faster
- django_template: 39.6 ms +- 0.4 ms -> 39.1 ms +- 0.5 ms: 1.01x faster
- xml_etree_parse: 163 ms +- 2 ms -> 162 ms +- 2 ms: 1.01x faster
- sympy_integrate: 24.4 ms +- 0.1 ms -> 24.1 ms +- 0.2 ms: 1.01x faster
- unpickle_pure_python: 279 us +- 2 us -> 276 us +- 2 us: 1.01x faster
- raytrace: 347 ms +- 3 ms -> 343 ms +- 2 ms: 1.01x faster
- scimark_sor: 134 ms +- 1 ms -> 133 ms +- 2 ms: 1.01x faster

Benchmark hidden because not significant (34): 2to3, crypto_pyaes, deltablue, dulwich_log, hexiom, html5lib, json_dumps, json_loads, logging_format, logging_simple, mako, meteor_contest, nqueens, pickle_pure_python, pidigits, python_startup, python_startup_no_site, regex_compile, regex_v8, scimark_lu, scimark_monte_carlo, spectral_norm, sqlalchemy_declarative, sqlalchemy_imperative, sqlite_synth, sympy_expand, sympy_sum, sympy_str, telco, tornado_http, unpickle_list, xml_etree_iterparse, xml_etree_generate, xml_etree_process

Geometric mean: 1.01x faster

+----------------------+
| dk_refcnt |
| dk_log2_size |
| dk_log2_index_bytess |
Copy link
Contributor

@hauntsaninja hauntsaninja Feb 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
| dk_log2_index_bytess |
| dk_log2_index_bytes |

@markshannon
Copy link
Member

markshannon commented Feb 22, 2022

Another nice speedup. Thanks.

@markshannon markshannon merged commit 1e34468 into python:main Feb 22, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants