Diego Giagio wrote:

> I've already tried returning ret_eagain, but it'll consume 100% CPU
> even with a single connection on the server.
>
> This happens when the thread is on 'process_active_connections' and
> there's not enought bandwidth to proceed. The thread will keep
> looping throught connections and finally return ret_eagain back to
> 'cherokee_thread_step_MULTI_THREAD', which in turn will ignore that
> return value and be called again on 'thread_routine' to process the
> next step, and so on.
>
> This will happen many many times if there's no bandwidth for a short
> period of time, which is very common, and consume 100% CPU.
>
> The solution for this problem on the patch is:
>
> 1 - Calculate the minimum sleep time based on the clock resolution
> for the current implementation. On recent Linux kernels it's 10ms,
> or 10000000ns.
> 2 - If there's no bandwidth for at least one connection, at the end
> of the loop that thread must sleep, otherwise keep going.
>
> I completely agree that this is not the best approach.
> Do you have any ideas?

  Have you seen that there are two main loop on the code?

  - The active connections loop: All the active connections are
    processed here. Here is where the server should do most of the
    work.

  - The polling connections loop: When a connection is waiting for I/O
    can be moved into this list, and the server will move it back if
    some I/O get available.

  We might create a new list in which me could "park" the connections
  for sometime. It would be something like: "I don't want to know
  about of this connection in the next X ms". After that, the server
  should take it back to the active connections list.

  In order to implement it, we should add a new list/heap to each
  thread structure, with an API like:

  cherokee_thread_move_connection_to_sleep (thd, conn, time)

  But now, we have to face a new problem: the main loop has a "sleep"
  period of one full second. This means, we are in troubles if we want
  to move back the connection in 50ms, for example.

  It might be a good idea to make dynamic the loop period: if there
  are not connections sleeping the default time is used: 1s;
  otherwise, it will use the minor of the sleeping values in the list.

  Do you know what I mean?

  More ideas? Thoughts?

--
Greetings, alo.
http://www.alobbs.com
_______________________________________________
Cherokee mailing list
[email protected]
http://www.alobbs.com/cgi-bin/mailman/listinfo/cherokee

Reply via email to