ezmsg-org / ezmsg

Pure-Python DAG-based high-performance SHM-backed pub-sub and multi-processing pattern
https://ezmsg.readthedocs.io/en/latest/
MIT License
15 stars 6 forks source link

Inspect tasks instead of assuming call signatures and return types #121

Closed griffinmilsap closed 6 months ago

griffinmilsap commented 6 months ago

Addresses #120.

Performance-wise there might be a barely significant speedup; possibly due to less hasattr checks and simpler branching/flow. All tests appear to pass.

Benchmark on my M1 Mac -- running test_perf.py -- many-dynamic-sizes:

Message size ASSUME (current impl.) INSPECT (new impl.)
32 b 14893 msgs/sec; 0.47 MB/s 15762 msgs/sec; 0.504 MB/s
512 b 14459 msgs/sec; 7.4 MB/s 16571 msgs/sec; 8.487 MB/s
8 kb 15572 msgs/sec; 127 MB/s 15951 msgs/sec; 130.67 MB/s
128 kb 10270 msgs/sec; 1346 MB/s 14399 msgs/sec; 1887 MB/s
2 Mb 4909 msgs/sec; 10296 MB/s 5463 msgs/sec; 11457 MB/s

Aside; I'm seeing some .. incomprehensible latency issues in the perf test. Something else to look into.

cboulay commented 6 months ago

Code looks good. I haven't tested it but I'm on the same arch as you so I don't think it'd help much ;)

griffinmilsap commented 6 months ago

@pperanich @cboulay I think this is good to go, I'm going to merge to dev; please do keep an ear to the ground if any of your systems break and give me a heads up before we push this to main