• Advertisement
Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    216625

Untitled

Sign in to follow this  

64 views

Well apparently I shouldn't have slept through the discussion on unit testing. The task scheduling system was/is somehow causing a slowdown with multiple threads (no idea why). Removing it from the test and just queueing the tasks in the thread pool provided these wonderous results. I upped the test duration just to prove to myself that the damn thing wasn't an anomaly.



WHEE. At least the thread pool works - that's the part I really wanted to get right. Fucking scheduler, I'll have to look at you now.
Sign in to follow this  


2 Comments


Recommended Comments

Awesome!! I knew it couldn't be straight threading issues. So many people are afraid of the context switching but it's really not something to worry too much about. Now spinning up new threads is something that does take a long time but if you've got a thread pool that already has them up and running then you're set.

Share this comment


Link to comment
I can see arguments for an against a thread pool - for tasks that are constantly done (ie, if you wanted a separate physics processing thread) then it would probably be better to just keep a thread running for it (thus removing the need to allocate a thread). But yeah, I wrote a thread pool class which spawns some threads and suspends them. It maintains a queue of tasks to do, which running threads will grab from. Under a load, it will activate as many already-allocated threads as it can to empty the queue. The threads auto-suspend themselves when they finish the task and the queue is empty.

I guess I could implement a similar system with the thread pool which would allow the programmer to specify tasks as "dedicated services", thus the pool would either spawn a thread for that task, or just assign one to it if it wasn't too busy.

I have too many projects, so this one is getting set aside for now anyway :P

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement