Re: Bug 324228 – support threadpool exiting idle threads



On Fri, 2005-12-23 at 12:24 -0500, Matthias Clasen wrote:
> For the idle timeout patch, I think we need to understand the desired
> behaviour a bit better, before rushing it in. My understanding of the
> current threadpool behaviour is the following:
> 
> 1) there is a global pool of idle threads, which can be restricted in
>   size by setting max-idle-threads to some non-negative number

This actually can be negative, you can have unlimited idle threads, this
means of course that none are cleaned up ever and the number of threads
increases depending on demand up to the maximum thread limit.

> 
> 2) threadpools take idle threads from the global pool to do their work
> 
> 3) if a threadpool has no more tasks to give to a thread, the thread is
>   moved back to the global idle threads pool after a delay of 0.5s
> 
> 
> Is the idea to make the delay in 3) changeable, or is the idea to
> introduce a second timeout that would cause threads to be removed from
> the global pool ? 

The idea from my point of view is for the thread to be removed from the
global pool after a timeout.

> Would this only kick in if all threadpools are idle ?

No, I think this should be specific to each thread.  A thread is given
work, and after it is complete, it has 'n' second before it exits.

> Should there be a min-idle-threads, to guarantee that at least some
> threads stay in the global pool, even if there is no activity for a long
> time ?

The current patch should do this.  It will wait for work up to the time
specified by the user (or forever if not specified) and then exit the
thread as long as the number of unused threads is respected.  

> It might be good to port gnome-vfs to gthreadpool now (that should be
> already possible, since the sorting api went in), and see if we actually
> need any extra tweaks.

Agreed.  I believe Gicmo has actually made a start on this, I will poke
him to find out how far he has got with it.  Essentially, GnomeVFS
needed the sort API, the idle timeout work is more for the Nokia 770 and
to reduce unnecessary work by such devices.

-- 
Regards,
Martyn




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]