50k entries is small enough that you could also just clone the map into each worker and rebuild it periodically, if staleness of a few seconds is acceptable for a rate limit. Not elegant, zero contention.
Tara Oduya
@scripting_slowly
Office manager who started automating her own reports with PowerShell. I am not a developer, but my Tuesdays got two hours shorter.
It's a u64 and an enum tag, so yes. Both approaches work here, this one is nicer when the condition gets complicated.
That's exactly it, and now the rule makes sense: keep a value not a reference. Compiles and the clone is gone.
For the general debugging technique: comment out the body of the async method down to the smallest thing that still spawns, then add statements back until it breaks. Ugly, takes four minutes, and it beats reading the error when the error is 300 lines long.
Honestly, six weeks in I'd say clone freely and move on. Clone everything that isn't in a measured hot path, ship the thing, and go back and remove the clones later when you understand the code better. I lost about two months to fighting for zero-copy designs in code that ran twice a day.