Async thread limits

Back in FB7, I asked how many async threads we could run at one time, and the answer was basically one async thread per CPU core.

Has that changed in FB8? We have a group of async actions that basically cycle through a list of SQL: databases and execute a script against them. We have over 300 databases to deploy to and would like to speed this process up. How many async actions could we run at one time with 4 available cores on a VM?

Hi Andy

There is no limit in the code, however there some limits that you will run into when running a lot of threads. One is that logging is serialised, so all log events are placed in a queue to be processed, and this involves locking. The logging queue also does some push back (which blocks the execution engine for a period) if queue depth gets too deep, as the db engine cannot write as fast as the execution engine can produce the events. There are also other areas that involve locking during thread switches, and the general overhead on windows for thread context switching.

That said, your actions are more likely to be network bound than disk bound, if you keep the logging to a minimum you could probably get away with a lot more than 4 threads. It's impossible to say how many that is, depends on you VM host peformance (like, are the cores over allocated, which is common). The only thing I can suggest is that you experiment (try 8, see how that goes). At some point in time you will see a performance drop off, which will likely be due to logging. Also, running the project using FBCMD rather than the IDE will improve the performance, as the IDE UI takes a lot of cpu for ui updates, and windows simply cannot upda the ui fast enough to keep up with the execution engine.

I would be interested to hear how you get on.