Comments on: Slim and light multitasking with fibers I agree, fibers are fantastic, especially for loading or latency hiding code. I've been using them a fair bit on my current project. However, there is one other gotcha that I think is worth mentioning, and that is that if you use fibers all throughout your game, and regularly have several fibers running, then it's incredibly important to get buy in from everyone, because you are basically running a "cooperative scheduling system" and if the other people in the company decide not to "cooperate" then you can end up with horrible priority inversion situations where system A runs for a really long time and hardly every yields, but system B which is quite time critical is set to a high priority in your internal scheduler, but keeps getting locked out by system A. Exactly the same problem can occur within a job/task manager, due to the cooperative nature of the scheduling, if someone *cough* H*vok *cough* decided that it's fine for them to monopolise some SPUs without yielding for a 3rd of the frame, then your other really imporant jobs that are feeding say.... the GPU can be left locked out.... with hillarious results! For that reason I now approach the widescale deployment of fibers with more caution than I once did. I still love them, I just try to make sure that either everyone invovled knows what the deal is, or limit their use to small contained areas that not everyone in the company can mess up! I agree, fibers are fantastic, especially for loading or latency hiding code. I’ve been using them a fair bit on my current project. However, there is one other gotcha that I think is worth mentioning, and that is that if you use fibers all throughout your game, and regularly have several fibers running, then it’s incredibly important to get buy in from everyone, because you are basically running a “cooperative scheduling system” and if the other people in the company decide not to “cooperate” then you can end up with horrible priority inversion situations where system A runs for a really long time and hardly every yields, but system B which is quite time critical is set to a high priority in your internal scheduler, but keeps getting locked out by system A. Exactly the same problem can occur within a job/task manager, due to the cooperative nature of the scheduling, if someone *cough* H*vok *cough* decided that it’s fine for them to monopolise some SPUs without yielding for a 3rd of the frame, then your other really imporant jobs that are feeding say…. the GPU can be left locked out…. with hillarious results!
For that reason I now approach the widescale deployment of fibers with more caution than I once did. I still love them, I just try to make sure that either everyone invovled knows what the deal is, or limit their use to small contained areas that not everyone in the company can mess up!

]]>
By: paulecoyote/2011/02/01/slim-and-light-multitasking-with-fibers/#comment-458 paulecoyote Thu, 03 Feb 2011 22:32:51 +0000 Good article. C# also has the yield keyword, though I believe it creates a state machine. Good article. C# also has the yield keyword, though I believe it creates a state machine.

]]>
By: Oddur Magnusson/2011/02/01/slim-and-light-multitasking-with-fibers/#comment-457 Oddur Magnusson Tue, 01 Feb 2011 23:25:59 +0000