From 3b7a75dfafa63113bc82dcc898af11b40bc48c8a Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 6 Nov 2025 11:46:31 +0000 Subject: [PATCH] mitogen: Send first stage as argv (786 bytes -> 796 bytes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This saves one layer of quoting/quote escaping in the bootstrap command and a string interpolation per connection. The cost is an increasing the bootstrap command by 10 bytes. I like the tradeoff. I could be convinced to revert it. ```console ➜ mitogen git:(boot-cmd--argv) ✗ ./preamble_size.py SSH command size: 796 Preamble (mitogen.core + econtext) size: 18230 (17.80KiB) Original Minimized Compressed mitogen.core 152237 148.7KiB 68453 66.8KiB 45.0% 18130 17.7KiB 11.9% mitogen.parent 99181 96.9KiB 51384 50.2KiB 51.8% 12956 12.7KiB 13.1% mitogen.fork 8445 8.2KiB 4139 4.0KiB 49.0% 1652 1.6KiB 19.6% mitogen.ssh 10847 10.6KiB 6913 6.8KiB 63.7% 2102 2.1KiB 19.4% mitogen.sudo 12089 11.8KiB 5924 5.8KiB 49.0% 2249 2.2KiB 18.6% mitogen.select 12325 12.0KiB 2929 2.9KiB 23.8% 964 0.9KiB 7.8% mitogen.service 41581 40.6KiB 22398 21.9KiB 53.9% 5847 5.7KiB 14.1% mitogen.fakessh 15753 15.4KiB 8135 7.9KiB 51.6% 2672 2.6KiB 17.0% mitogen.master 52891 51.7KiB 27586 26.9KiB 52.2% 7129 7.0KiB 13.5% ``` --- mitogen/parent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 9668a85b..ab40a87f 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1488,7 +1488,8 @@ class Connection(object): '-c', 'import sys;sys.path=[p for p in sys.path if p];' 'import binascii,os,select,zlib;' - 'exec(zlib.decompress(binascii.a2b_base64("%s",-15)))' % (encoded.decode(),), + 'exec(zlib.decompress(binascii.a2b_base64(sys.argv[1]),-15))', + encoded.decode(), ] def get_econtext_config(self):