Per-task logging costs a third of worker throughput
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend, cli, observability, performance
Línea de trabajo
Start with threadmill/executor.py, especially configure_logging, the worker command options, and the per-task executor log calls. Trace how TaskExecutor receives logging configuration and how Django's task signal receivers inherit the root level. Done means the worker exposes a configurable level, avoids forcing INFO, and treats per-task executor messages as debug detail while preserving operator control of django.tasks.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Profiling a drain (20,000 echo tasks, one process, one thread, prefetch 128) puts logging at roughly 70 µs of client CPU per task, against a recorded per-task wall of 184 µs. That is about 38% of the worker's throughput, and it is the single largest Python cost in the loop - larger than the Redis round trips it sits next to.
What emits four JSON records per task
threadmill/executor.pylogsExecuting task ...and thenTask ... succeeded(or failed) at INFO for every task.- Django's own
django.tasks.signalsreceivers (log_task_started,log_task_finished) log once more each. They are registered at import and sit at NOTSET, so they inherit the root logger's level. threadmill/executor.py'sconfigure_loggingsets the root logger toINFOunconditionally, so all four records are formatted and written.- The worker's default formatter is
JsonFormatter, which builds a payload dict andjson.dumpses it per record, then writes to stdout and flushes.
Measured inside that 70 µs: 51 µs in StreamHandler.emit and 36 µs in JsonFormatter.format/json.dumps - the formatting, not the log call itself. record_task's lock, by contrast, costs 0.35 µs, and normalize_json 0.5 µs.
Why this is a defect and not just a tuning knob
There is no way to quieten a production worker: configure_logging hardcodes root_logger.setLevel(logging.INFO), and the command exposes --log-format but no --log-level. A deployment that wants WARNING output cannot get it, and it pays a JSON encode and a stdout flush per task for the privilege.
Suggested fix
- Add a level option to the worker command (and to
TaskExecutor), defaulting to something quiet. - Demote the two per-task executor records to
DEBUG; "task started/succeeded" is trace-level detail, and the task itself is the interesting signal. - Leave the level of
django.tasksto the operator rather than forcing the root logger to INFO.
Benchmark fairness
The comparison harness runs celery and dramatiq with --loglevel=WARNING, while threadmill currently cannot run below INFO, so part of the chart gap is threadmill logging its own benchmark. Fixing this makes the comparison apples-to-apples as well as making production faster.
Discovered while validating per-task performance claims; the profiling numbers are from a loaded machine, so treat the shares as the durable result and the absolute microseconds as this box's.
- Lenguaje dominante
- Python
- Estrellas
- 21
- Forks
- 2
- Merge medio
- 12 h 39 min
- PR fusionados (30 d)
- 27
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
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.
Issues similares
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
good first issue module-baseline needs triage ux
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
darnitdevorg/darnit#650 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
nyjc-computing/campus#938 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
nf-osi/nf-metadata-dictionary#1027 ·
Los mantenedores suelen responder en 1 día
-
bug documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
qatrackplus/qatrackplus#913 ·
Los mantenedores suelen responder en 3 días