Skip to content

Experiment: Configurable Pickle protocol version#1416

Draft
moreati wants to merge 1 commit into
mitogen-hq:masterfrom
moreati:mitogen.pickle_protocol
Draft

Experiment: Configurable Pickle protocol version#1416
moreati wants to merge 1 commit into
mitogen-hq:masterfrom
moreati:mitogen.pickle_protocol

Conversation

@moreati

@moreati moreati commented Jan 14, 2026

Copy link
Copy Markdown
Member

Mitogen currentl uses Pickle protocol 2, regardless of the Python versions. This constrains performance under Python 3 (#485). Configurable Pickle protocol would improve performance when exclusively using Python 3

Protocol 2

mitogen git:(mitogen.pickle_protocol) ✗ .venv/bin/python3.14 tests/bench/throughput.py --ssh-host d13.lan --ssh-python python3 
2
Testing local()...
local() took 2734.70 ms to transfer 512.00 MiB, 187.22 MiB/s
Testing ssh(compression=False)...
ssh(compression=False) took 36714.61 ms to transfer 512.00 MiB, 13.95 MiB/s
Testing ssh(compression=True)...
ssh(compression=True) took 43327.35 ms to transfer 512.00 MiB, 11.82 MiB/s

Protocol 3

mitogen git:(master) ✗ MITOGEN_PICKLE_PROTOCOL=3 .venv/bin/python3.14 tests/bench/throughput.py --ssh-host d13.lan --ssh-python python3
3
Testing local()...
local() took 324.69 ms to transfer 512.00 MiB, 1576.91 MiB/s
Testing ssh(compression=False)...
ssh(compression=False) took 22553.84 ms to transfer 512.00 MiB, 22.70 MiB/s
Testing ssh(compression=True)...
ssh(compression=True) took 21976.54 ms to transfer 512.00 MiB, 23.30 MiB/s

@moreati

moreati commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

SSH benchmarks were over WiFi

@moreati

moreati commented Jan 14, 2026

Copy link
Copy Markdown
Member Author

Cousin of #1416, knowing python version of contexts would allow dynamically choosing best supported Pickle protocol.

@moreati moreati force-pushed the mitogen.pickle_protocol branch from 9865e9d to 9708231 Compare January 23, 2026 10:58
@moreati

moreati commented Jan 23, 2026

Copy link
Copy Markdown
Member Author

Little to no speed-up of single-shot benchmark

mitogen git:(mitogen.pickle_protocol) ✗ hyperfine --warmup 1 'python3.14 hello_local2.py' 'PICKLE_PROTOCOL=3 python3.14 hello_local2.py'        
Benchmark 1: python3.14 hello_local2.py
  Time (mean ± σ):     190.0 ms ±   1.9 ms    [User: 119.3 ms, System: 20.9 ms]
  Range (min … max):   187.1 ms … 194.4 ms    15 runs
 
Benchmark 2: PICKLE_PROTOCOL=3 python3.14 hello_local2.py
  Time (mean ± σ):     188.7 ms ±   1.8 ms    [User: 118.3 ms, System: 20.6 ms]
  Range (min … max):   186.4 ms … 192.2 ms    15 runs
 
Summary
  PICKLE_PROTOCOL=3 python3.14 hello_local2.py ran
    1.01 ± 0.01 times faster than python3.14 hello_local2.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant