fd_set implementation is inefficient
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
- 35/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- c, wasm
- Área
- operating-systems
Línea de trabajo
Comience revisando las cabeceras relacionadas con select referenciadas en el issue: __macro_FD_SETSIZE.h, __typedef_fd_set.h, _fd_set.h y sys/select.h de musl. Compare la representación actual de fd_set con las restricciones de POSIX y determine el alcance requerido y el impacto en la compatibilidad. Done debe incluir una dirección de implementación acordada y la validación correspondiente del comportamiento de select y FD*.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
cloudlibc seems to have made a design choice that POSIX does not require, and what most *NIX implementations don't support. this has led to cloudlibc using a lot more memory supporting scenarios with select() that is better served by poll(). imo this should be revisited by basically deleting the cloudlibc logic entirely.
first, let's start with what POSIX says:
- fd_set type
The <sys/select.h> header shall define the fd_set type as a structure.
The <sys/select.h> header shall define the following symbolic constant, which shall have a value suitable for use in #if preprocessing directives:
FD_SETSIZEMaximum number of file descriptors in an fd_set structure.
The requirement for the fd_set structure to have a member fds_bits has been removed as per The Open Group Base Resolution bwg2001-005. - select()
The behavior of these macros is undefined if the fd argument is less than 0 or greater than or equal to FD_SETSIZE, or if fd is not a valid file descriptor, or if any of the arguments are expressions with side-effects.
let's look at what cloudlibc does:
FD_SETSIZEset to1024- fd_set type
int __fds[FD_SETSIZE];-- an array of integers (fds)
- FD_* macros
- the index into
__fdsis just "the next used fd" - the value in
__fdsis the fd to check
- the index into
- end result:
- scanning the
__fdsarray takes exactly__nfdschecks (good) sizeof(fd_set)is 4100 bytes (bad)- still has a max nfds of
FD_SETSIZE(fine) - any valid fd can be monitored with
select(), not just[0, FD_SETSIZE)(good)
- scanning the
let's look at what musl (and basically every other *NIX library out there) does:
- sys/select.h
FD_SETSIZEset to 1024unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];-- a bitmask of fds- the index into
fds_bitsis the fd to check - the value is a single bit and whether to check the fd
- end result:
- scanning
fds_bitstakes longer, but most architectures have "bit is set" insns to optimize this. an unoptimized implementation would take at least 128 tests (FD_SETSIZE / 8) (meh) sizeof(fd_set)is 128 bytes (good)- still has a max nfds of
FD_SETSIZE(fine) - only valid fd's within
[0, FD_SETSIZE)can be monitored withselect()(fine)
- scanning
so cloudlibc uses 4k of memory instead of 128bytes in order to be slightly faster and to support fds larger than FD_SETSIZE. but no POSIX-compliant project would ever use an fd >= FD_SETSIZE, which means they'd be making assumptions that the underlying code is cloudlibc.
WASI API isn't relevant because it doesn't define fd_set, and this is purely about the select() API which is entirely part of WASI libc.
- Lenguaje dominante
- C
- Estrellas
- 1k
- Forks
- 268
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 20
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de WebAssembly/wasi-libc
-
wasip2: enabling O_APPEND with fcntl reuses the old positional output stream and overwrites the fileAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
WebAssembly/wasi-libc#919 ·
Los mantenedores suelen responder en 1 día
-
wasip2/wasip3: reads never see data appended to a file after reaching EOFPosiblemente ocupada @libsmol la tomó hace 25 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 61/100
WebAssembly/wasi-libc#889 ·
Los mantenedores suelen responder en 1 día
-
Contradicting `SOL_TCP` and `SOL_UDP` definition for p1Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
WebAssembly/wasi-libc#855 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
MIT licensing state is unhealthyAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
WebAssembly/wasi-libc#815 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
WebAssembly/wasi-libc#809 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de WebAssembly/wasi-libc
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
389ds/389-ds-base#8152 ·
Los mantenedores suelen responder en 2 días
-
meta:feature-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
mpv-player/mpv#18855 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[FIX]: File Tree in appAbiertobug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition rootPosiblemente ocupada @tuhaihe la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/cloudberry#2356 ·
Los mantenedores suelen responder en 2 días