Branch: Tag:

2014-11-10

2014-11-10 16:08:19 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Reduce the number of dynamically created threads.

This patch pushes most of the dynamically created threads into the
running local_backend. It specifically does not push the gotdatarowdesc
one to avoid deadlocks.

93:    return realbuffer->stashflushmode;   }    + protected inline mixed callout(function(mixed ...:void) f, +  float|int delay,mixed ... args) { +  return local_backend->call_out(f,delay,@args); + } +    // Some pgsql utility functions      class PGplugbuffer {
190:    error("Out of range %d\n",howmuch);   #endif    if(fillread) { -  array cid=local_backend->call_out(gottimeout,timeout); +  array cid=callout(gottimeout,timeout);    Thread.MutexKey lock=fillreadmux->lock();    fillread.wait(lock);    lock=0;
652:    _setrowdesc(datarowdesc);    mapping(string:mixed) tp=_tprepared; // FIXME Is caching this worthwhile?    if(!tp || !tp.datarowdesc) -  Thread.Thread(gotdatarowdesc); +  Thread.Thread(gotdatarowdesc); // Do not use callout, it deadlocks    if(tp)    tp.datarowdesc=datarowdesc;    }
855:    array(mixed) args) {    int|array datarow;    while(arrayp(datarow=_datarows->read_array())) -  callback(this, datarow, @args); +  callout(callback, 0, this, datarow, @args);    trydelayederror();    eoffound=1; -  callback(this, 0, @args); +  callout(callback, 0, this, 0, @args);    }       //! Sets up a callback for every row returned from the database.
879:    array(mixed) args) {    array(array|int) datarow;    while((datarow=_datarows->read_array()) && arrayp(datarow[-1])) -  callback(this, datarow, @args); +  callout(callback, 0, this, datarow, @args);    trydelayederror();    eoffound=1;    if(sizeof(datarow)>1) -  callback(this, datarow=datarow[..<1], @args); -  callback(this, 0, @args); +  callout(callback, 0, this, datarow=datarow[..<1], @args); +  callout(callback, 0, this, 0, @args);    }       //! Sets up a callback for sets of rows returned from the database.