Skip to content

Add bm_base64 covering common base64 module APIs - #447

Merged
gpshead merged 6 commits into
python:mainfrom
gpshead:add-bm_base64
Jan 3, 2026
Merged

Add bm_base64 covering common base64 module APIs#447
gpshead merged 6 commits into
python:mainfrom
gpshead:add-bm_base64

Conversation

@gpshead

@gpshead gpshead commented Dec 29, 2025

Copy link
Copy Markdown
Member

Motivation python/cpython#143262 but also in general this wasn't covered and @serhiy-storchaka is also doing work in this area that'll become relevant such as python/cpython#143216.

@gpshead

This comment was marked as resolved.

@gpshead
gpshead marked this pull request as ready for review December 29, 2025 05:59

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What are the results and the total time?

My suggestions:

  • Test an ASCII string input for decoding.
  • Balance encoding and decoding.
Comment thread pyperformance/data-files/benchmarks/bm_base64/run_benchmark.py Outdated
Comment thread pyperformance/data-files/benchmarks/bm_base64/run_benchmark.py Outdated
Comment thread pyperformance/data-files/benchmarks/bm_base64/run_benchmark.py
Comment thread pyperformance/data-files/benchmarks/bm_base64/run_benchmark.py
@gpshead

gpshead commented Jan 2, 2026

Copy link
Copy Markdown
Member Author

Example results comparing before and after python/cpython#143262.

main-before-opt-b64.json
========================

Performance version: 1.14.0
Python version: 3.15.0a3+ (64-bit) revision 6b9a6c6ec3b
Report on Linux-6.17.0-8-generic-x86_64-with-glibc2.42
Number of logical CPUs: 15
Start date: 2026-01-02 06:47:53.863590
End date: 2026-01-02 06:54:17.985677

main-after-opt-b64.json
=======================

Performance version: 1.14.0
Python version: 3.15.0a3+ (64-bit) revision 61fc72a4a43
Report on Linux-6.17.0-8-generic-x86_64-with-glibc2.42
Number of logical CPUs: 15
Start date: 2026-01-02 06:30:08.791666
End date: 2026-01-02 06:36:26.047033

### ascii85_large ###
Mean +- std dev: 1.04 sec +- 0.01 sec -> 1.03 sec +- 0.01 sec: 1.01x faster
Not significant

### ascii85_small ###
Mean +- std dev: 20.7 ms +- 0.3 ms -> 20.6 ms +- 0.4 ms: 1.00x faster
Not significant

### base16_large ###
Mean +- std dev: 6.39 ms +- 0.06 ms -> 6.36 ms +- 0.04 ms: 1.00x faster
Not significant

### base16_small ###
Mean +- std dev: 376 us +- 3 us -> 372 us +- 3 us: 1.01x faster
Not significant

### base32_large ###
Mean +- std dev: 585 ms +- 8 ms -> 586 ms +- 7 ms: 1.00x slower
Not significant

### base32_small ###
Mean +- std dev: 11.4 ms +- 0.1 ms -> 11.5 ms +- 0.1 ms: 1.00x slower
Not significant

### base64_large ###
Mean +- std dev: 4.66 ms +- 0.03 ms -> 2.06 ms +- 0.01 ms: 2.26x faster
Significant (t=749.12)

### base64_small ###
Mean +- std dev: 314 us +- 5 us -> 253 us +- 5 us: 1.24x faster
Significant (t=64.73)

### base85_large ###
Mean +- std dev: 432 ms +- 4 ms -> 431 ms +- 4 ms: 1.00x faster
Not significant

### base85_small ###
Mean +- std dev: 8.37 ms +- 0.08 ms -> 8.39 ms +- 0.12 ms: 1.00x slower
Not significant

### urlsafe_base64_small ###
Mean +- std dev: 511 us +- 5 us -> 445 us +- 4 us: 1.15x faster
Significant (t=80.03)

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am going to add also ignorechars to support decoding multi-line data. So it may be worth to separate "raw" and "multi-line" cases, if we want to compare the effect of optimization. We could also separate encoding and decoding. But then we will have too much tests. So this is up to you.

@gpshead

gpshead commented Jan 3, 2026

Copy link
Copy Markdown
Member Author

yeah i'd initially started out with separate encode/decode but the matrix of benchmark cases got large and pyperformance is not really intended as a microbenchmark. improvements in any of these will be reflected in the overall scores.

@gpshead
gpshead merged commit 0976e4a into python:main Jan 3, 2026
19 checks passed
maurycy added a commit to maurycy/pyperformance that referenced this pull request Jan 23, 2026
* main:
  Replace pre-commit with prek in CI and add cooldown to Dependabot (python#452)
  Add bm_base64 covering common base64 module APIs (python#447)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants