Provide a way to mark thread as offline and then online again

Abierto
#4,839 13 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
c

Línea de trabajo

Comienza leyendo el comportamiento de libuv descrito para uv_prepare, uv_check y uv_loop_configure, centrándote en el orden de las callbacks alrededor del sondeo de I/O. Determina si la transición offline/online solicitada puede exponerse sin comprometer el bucle, y define el comportamiento requerido de la API y la cobertura antes de la implementación.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Little bit of background: BIND 9 is using libuv in multi-threaded environment (with per-thread uv_loop) and it uses userspace-rcu for (some) memory reclamation. Userspace-RCU has several modes of operation, we are currently using memory barriers, but there's also this nice QSBR mode (I can link to a paper) that has no read overhead, but requires periodic calls to a function to say "I'm doing nothing" (quiescent-state).

All is fine, but if one of the threads would receive no traffic at all (for some reason - perhaps REUSEPORT load-balancing is wrong) then no memory reclamation would ever happen. This is preventable by marking the thread as "offline" before calling "select/poll/epoll/whatever". This is fine as uv_prepare can be used for this.

However, the thread needs to be marked as online again before any of the userspace-rcu memory reclamation can be used and the uv_check can't really be used for this as this is not really true:

Check handles will run the given callback once per loop iteration, right after polling for i/o.

Now, I don't remember who and where this was discussed, but I do remember somebody (@bnoordhuis) said that there is some i/o processed before the uv_check callback is called. And that is problematic, because the thread needs to be marked as online before any networking callbacks are called.

Would it be possible to actually make uv_check to run before any i/o callbacks are called without compromising speed and make this either universally available or add this as flag to uv_loop_configure()?

Lenguaje dominante
C
Estrellas
27.4k
Forks
4k
Merge medio
4 d 14 h
PR fusionados (30 d)
23

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de libuv/libuv

Todos los issues de libuv/libuv

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.