Async ant colony simulation?

Anyone here wrote an ant colony simulation (or anything with 'many' 'small' agents) with async Rust where each ant is it's own async task ?

If so, how many ants were you able to scale up to / what ended up being the bottleneck / sample code ?


1 Like

I can't speak for ant colony simulations, but I think some general benchmarking is in order. I would setup a simple test bench where it times how long it takes to perform some units of work, via threads or async tasks. These units of work generically represent some ant work, which takes some constant time to complete.

Simpily run the threaded test bench program with an increasing amount of work. Do the same with the async task version. I would even try to benchmark groups of work with a threadpool.

If you graph it, you'd see the x axis is units of work, and the y axis is time to complete that work. I'd speculate that some point, the overhead of managing many small async tasks may start to kill performance. If you plot the threaded version, async task version and or threadpool veraion, it may answer your question as to if async tasks is worth it.

The benchmarking may show there may be a ballance between how many async tasks / threads to use and how much work you do on those threads. IE too many threads = too much overhead managing them vs doing too much work on a thread = wasted time as you could have parallelised it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.