I’m still playing with small exercises, one interesting is “alphametics” (it’s available on exercism). Exercise goal is to evaluate if an expression like “SEND + MORE == MONEY”, when letters are replaced uniquely with numbers, is valid equation (more details in link above). As I have written in previous article, I try to think about performance and this exercise was quite interesting from that perspective.
Continue reading Can Hashmap Be An Obstacle on Road to PerformanceTag Archives: performance
How much better is the thread pool?
Is thread pool worth to consider for my project? I was looking for some opinions around the net and as usual they differ and most common wisdom is it matters. Generally it’s “known” that creating and tearing down thread is “significant” overhead, so if you have a lot of small tasks thread pool is much better solution then spawning new thread for each task. But what is significant overhead? According to what I read time to create thread on Linux should be about 10μs (which does not look as too much to me) and app. 2MB of memory allocated for stack (configurable). I was considering thread pool in context of audioserve project, where I started with simplest possible solution (e.g. spawning individual threads ) and was wondering how much I’m loosing by not using thread pool. So I implemented simple thread pool (as learning exercise – long term audioserve solution should use tokio-threadpool) and add it to audioserve. In the remainder of this short article I’d like to share my findings and roughly quantify benefits of thread pool for such small project. Continue reading How much better is the thread pool?