Updating the witness map is a fairly expensive operation, since we must append new nodes to a tree. This operation is linear to the amount of notes that haven't been spent yet, and each insertion is logarithmic. In total, we spendO(N log N) time, which is less than ideal, since that code is run from an async context.
https://github.com/anoma/namada-masp-indexer/blob/6cc34cd451cf4f6ab60c8e4838c486d831534aaa/chain/src/main.rs#L218-L239
Since this blocks tokio from yielding the current worker thread, we should resort to tokio::task::block_in_place around this for loop.
Updating the witness map is a fairly expensive operation, since we must append new nodes to a tree. This operation is linear to the amount of notes that haven't been spent yet, and each insertion is logarithmic. In total, we spend
O(N log N)time, which is less than ideal, since that code is run from anasynccontext.https://github.com/anoma/namada-masp-indexer/blob/6cc34cd451cf4f6ab60c8e4838c486d831534aaa/chain/src/main.rs#L218-L239
Since this blocks
tokiofrom yielding the current worker thread, we should resort totokio::task::block_in_placearound this for loop.