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

Feature/performance enhancement: Message Caching #6

Closed griffinmilsap closed 1 year ago

griffinmilsap commented 1 year ago

This pull request implements message caching local to each process. Messages are assigned unique message IDs and assigned to the local message cache. Subscribers always check the cache for the message before trying to reconstitute a version of the message from shared memory.

This enhancement makes it such that no (de)serialization or message copies are required for pubs/subs that exist together in the same process.

pperanich commented 1 year ago

In running test_perf against main, I am noticing a decrease in max effective send rate ~7ksamps/s vs ~9ksamps/s. Overall bandwidth appears to be slightly decreased as well. Running on x86_64-darwin, python 3.11.

griffinmilsap commented 1 year ago

@pperanich That's on me... I had to change the message size of the perf test to debug something and never changed it back. I've pushed a change that allows an apples-to-apples comparison.

griffinmilsap commented 1 year ago

It also turns out that calculating backpressure with every message was resulting in a pretty severe performance regression. That's been addressed and I'm now seeing identical performance for small message sizes between the main branch and this one.