May anyone help to explain this code by Jose in Broadway to me?

The code above could be replaced by a map. The only reason we are using the process dictionary is because sometimes we are handling dozens of thousands of events per second, and in this case the map operations start showing up in benchmarks, so we use the mutable process dictionary instead.

I want to make it clear that people shouldn’t really be doing this in practice unless they benchmark and see an order of magnitude difference. In all my time with Erlang, I had to do this trick only twice, here and on GenStage, and both for the same reason.

19 Likes