(Recreated based off of master now)
This adds support for a variant on TaskFiber which pools fibers for a given thread. This is primarily a triage patch for JRuby 1.7.5+ which isn't currently pooling the threads that back its fibers, resulting in a ridonkulous amount of CPU burn as it spins up a new thread per Fiber. See jruby/jruby#1443 for full details there.
This is the same fiber pattern used by rack-fiber_pool, among others. In my tests, it's completely eliminated the JRuby CPU thrashing, and actually improved performance of Celluloid under MRI, too.
Using this very unrigorous benchmark, I saw the following results:
Big refactor of the FiberPool; now maintains an internal pool, resume…
…s fibers to let them finish when trimming them. Fixes thread growth issues; fibers left unresumed on dead threads are still an issue under JRuby though. Will need a JRuby fix to address.
headius patched in thread pooling for fibers into JRuby, and I ran some quick rough performance tests with patched and unpatched versions of JRuby, with and without the fiber pool at jruby/jruby#1443. I'm seeing:
This would suggest that even when JRuby is fixed, it would be prudent to use an application-level fiber pool when possible.
@cheald not sure what happened here... why this collected dust.
Are you still using this code yourself? I will factor this into #512
We are still using it with great success, yes.
I am very excited to test this myself @cheald and bring it in. So this effectively creates a third possible task class, correct; in your implementation it's an alternative to TaskFiber and TaskThread?
So far, this is amazing @cheald. I need to test it further but in my extremely complicated implementation it seems like it's removing issues I've been stuck with congestion-wise for years.
@tarcieri I think this is a separate gem -- celluloid-taskpooledfiber
I'd like to get pools out of core entirely FWIW
Agreed, #512 -- I'm saying this is another pool oriented gem.
I'm all for multiple competing pool gems 😉
Including this one:
Right on. I have it coexisting well with the existing pool implementation, but it's different enough to where I wouldn't want to lump it into celluloid-pool
That looks good also ( celluloid-coordinator ) -- I'll bring that over also. And I think I may have another myself that I call spans but that can hold a while probably.
Yeah, #478 is looking really good right about now.
Sorry, I've been out all evening. Yes, this is simply an alternate Task type. If it's desired, I can publish it as a gem; shouldn't be too hard.
Dinged you on LinkedIn in on the topic, I was going to ask if you'd mind being attributed and I'd cut the gem for you either stand-alone or in celluloid-extras so it can be actively maintained and kept current with changes as they happen in the API ( unless you are prepared to do that ). There are several pieces of Celluloid being decoupled so it'd be in good company.
Oh, that's fine. I just pushed https://github.com/cheald/celluloid-task-pooled-fiber but I'm happy to nuke it if it's already in motion to be made available somewhere.
BTW, if you want, I'm happy to just give you the commit bit on that repo, too. Whatever's easiest - we're definitely going to be using TaskPooledFiber for a long while, so I will have a vested interest in keeping it maintained. :)
I went ahead and pushed https://rubygems.org/gems/celluloid-task-pooled-fiber - if this ends up getting rolled into another gem I'll just pull it.
The way you've got it now will work out totally fine. I look forward to maintaining this together. I'm very impressed with its performance in my use so far. My own platform is like new, snappier than ever before. Glad this code came back to the foreground. Excited to see it widely used.
This will be well taken care of, with your cooperation or approval of any decisions, in #549 once the new API changes land.