mario-eth / soldeer

Solidity Package Manager written in rust
MIT License
240 stars 26 forks source link

Lock-free synchronization, parallelize cpu bound tasks, add rayon #195

Closed crypdoughdoteth closed 2 months ago

crypdoughdoteth commented 2 months ago
mario-eth commented 2 months ago

Hey, i really appreciate the effort!! Unfortunately we have a version 0.4.0 that is in the making which probably solves lots of these. If you mind looking into the release/0.4.0 branch to see.

beeb commented 2 months ago

If you're willing to re-implement the changes based on branch release/v0.4.0 please note that we use the nightly rustfmt!

beeb commented 2 months ago

Did you measure contention on the mutex? In practice it takes a fraction of a second to hash all the dependencies so I have not observed degraded performance.

crypdoughdoteth commented 2 months ago

My pleasure, I reimplemented against the v0.4.0 branch and will open a new PR shortly 🫡

re: Mutex: I did not measure the contention levels, but contention is the worst case scenario for Mutex performance. Each thread is attempting to write to the same memory location in a very short time slice in both instances. This can become an issue when projects gets larger and there is simply more hashes and files names to write. The best case is pointer chasing (a serially-dependent chain of loads to access the underlying data), which strictly underperforms MPSC in this case. Interior mutability is best to avoid if there's a better solution.