5 ms·
That would be a very interesting metric, could you grep|wc them and the locs?
by KingOfCoders 4y ago
That would be a very interesting metric, could you grep|wc them and the locs?
- mplanchard 4y agoSure! Tokei says that we've got ~76k lines of Rust. I used ripgrep to find occurrences of `Arc::` (to exclude type signatures and only find constructors) and then just gave it a quick manual look to exclude tests and benchmarks. This leaves me with: - one data structure that contains general application state and contextual information, which is created at application startup and shared across all tasks/threads - one data structure for accumulating results that is shared across threads. This is an Arc<Mutex<u64, SomeEnum>>. The less common of the two enum variants is an Arc<BTreeMap>. - one data structure used to pass a database connection in to a context where it'll be used to spawn async tasks All told, we've only got four places in production paths where we construct a new Arc. One of those four is only called once in the life cycle of the application, while the others are called for any given invocation.
- KingOfCoders 4y agoYou're comment made my day, thanks for your work!
- mplanchard 4y agoHey no problem! I was glad my guess wasn’t too far off, and it was fun to go digging to check.