unionlabs/union

optimize queue-msg normalization pass

Closed this issue · 0 comments

the normalization pass for queue-msg is quite inefficient. since this function is called on every message pushed into the queue, and on the output of every optimization pass, this needs to be optimized. it was copied from the previous implementation which had each step as a separate pass, but it can now be consolidated into one:

https://github.com/unionlabs/union/blob/86265eb82991586ec571b2540613589216c48a13/lib/queue-msg/src/normalize.rs

the main two inefficiencies are:

  1. allocates new Vecs for every step for both the parent id indexes and output Ops
  2. descends into the Ops multiple times

fixing these will essentially require a bottom-up rewrite of the normalization pass.

requirements:

  • all existing (non-commented-out) tests must still pass
    • if a semantic bug in one of these tests is found, then keep that test as a failure case and write a new test for the correct semantics.
  • benchmarks for comparison with current and new

Note

i've marked this as E-easy since this is a very isolated component. i am willing to provide mentoring on this task if desired.