ijiraq/cadcVOFS — pull request #24 by edwardchapin (2014-03-21 19:43:31+00:00)
Title: S1543: cap number of threads used to flush (upload) files to VOS

I implemented this cap by replacing instantaneous creation of new threads for each call to flushNode() with a queue of worker threads (that is shared among all FileHandles created by a single Cache object). Two interesting features:

- In my first try at this, the worker threads were started at the time of Cache object initialization which occurred before FUSE started, after which the workers seemed to get killed. So, the queue is initialized / workers started the first time they are needed (after FUSE init).

- The exclusive writerLock was originally acquired inside flushNode (which runs in a separate thread). However, now that flushNode may not be called for a while as it sits in a queue, it is instead acquired by the process that puts the job into the queue (and waits for it to finish). More code is now included in the locked block than before, so this may cause additional waiting that didn't happen before.