Threads inside preprocessing steps
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 8/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- performance
Línea de trabajo
This is a design proposal, not a task. Its open questions are whether max_threads_per_worker should also set threads inside a step, and whether global common_reference should be the first PR. The issue names thread_budget, a ContextVar, and the perf/thread-budget and bench/all-threads branches, but no repository file paths. Wait for a maintainer answer to the questions before writing code.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I'd like each preprocessing step to be able to split its own work across threads, independently of the chunk executor. At the moment n_jobs is the only way to run preprocessing in parallel, and each extra job holds its own chunks in RAM. Saving a phase shift, bandpass and median reference with 1 job on 8 threads runs at 162 MS/s in 0.13 GB, against 264 MS/s in 1.72 GB with 8 jobs.
This is one possible answer to @h-mayorquin's question on #4840 about which execution controls users need across preprocessing, alongside the RAM survey in #4837.
Proposal
- A thread budget says how many threads a step may use.
with thread_budget(n):sets it around any code, and the chunk executor sets it in each job frommax_threads_per_worker, which today only limits BLAS threads. The default is 1, so nothing changes until a user raises it. - A step that can split its work asks a private helper for a thread pool sized to the budget. Work handed to that pool gets a budget of 1, so a step called from it can't start threads of its own.
- The budget is held in a
ContextVar, so steps that don't use threads, such asscale, don't have to pass it on. - Each threaded step's output is bit-identical to one thread.
Jobs × threads trades memory for speed
Left: 1 s of 384 channels, both axes log scale; the coloured lines are the whole chain. Right: saving 30 s of the chain, labelled jobs × threads.
Saving 30 s of phase_shift(method="fir") → bandpass → median common_reference on 8 cores:
| jobs × threads | FIR bandpass | IIR bandpass, banks of 16 |
|---|---|---|
| 1 × 1 | 66 MS/s, 0.13 GB | 45 MS/s, 0.13 GB |
| 1 × 8 | 162 MS/s, 0.13 GB | 134 MS/s, 0.20 GB |
| 4 × 2 | 252 MS/s, 0.87 GB | 172 MS/s, 0.93 GB |
| 8 × 1 | 264 MS/s, 1.72 GB | 187 MS/s, 1.78 GB |
1 s chunks on tmpfs, median of 3, peak RAM above baseline, i9-12900K. MS/s counts channel-samples; one probe in real time is 11.5 MS/s.
8 jobs are the fastest, but they use 13 times the RAM of 1 job with 8 threads. 1 job with 8 threads is still 2.5 to 3 times faster than 1 × 1. These come from one machine, and my bank timings differ from @h-mayorquin's.
Each step splits its work in its own way, on 1 s of 384 channels:
| step | split by | 1 thread | 8 threads |
|---|---|---|---|
| IIR bandpass | banks of 16 channels | 81 MS/s | 361 MS/s |
| FIR bandpass | slabs of channels | 161 MS/s | 731 MS/s |
| FIR phase shift | blocks of samples | 616 MS/s | 3,010 MS/s |
median common_reference |
blocks of samples | 315 MS/s | 1,777 MS/s |
| whole chain, FIR bandpass | each step as above | 87 MS/s | 425 MS/s |
| whole chain, IIR bandpass | each step as above | 55 MS/s | 274 MS/s |
Code
The budget is about 80 lines on perf/thread-budget, where global common_reference uses it. The other steps are threaded on bench/all-threads, on top of #4563, #4853, #4854, #4855 and #4856, with the IIR filter in banks of 16 channels as in #4840.
Questions
- Should
max_threads_per_workerset the threads inside a step, or should this be a separate execution setting? - If this direction is welcome, would you take global
common_referenceas the first PR, with each other step following once its base PR merges?
- Lenguaje dominante
- Python
- Estrellas
- 883
- Forks
- 291
- Merge medio
- 3 d 17 h
- PR fusionados (30 d)
- 40
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 SpikeInterface/spikeinterface
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
SpikeInterface/spikeinterface#5008 ·
Los mantenedores suelen responder en 2 días
-
`plot_potential_merges` draws the correlograms of other units when a merge group is not sortedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
SpikeInterface/spikeinterface#5007 ·
Los mantenedores suelen responder en 2 días
-
`plot_unit_presence` shows bin indices on the `Time (s)` axis when `time_range` is not givenAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
SpikeInterface/spikeinterface#5006 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
SpikeInterface/spikeinterface#5005 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
SpikeInterface/spikeinterface#5004 ·
Los mantenedores suelen responder en 2 días
Todos los issues de SpikeInterface/spikeinterface
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
daniel-ospina/tortoise#15308 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
difficulty:easy prio:low type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NatronGitHub/Natron#2405 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Jstar269/nakagawa-recomp#3746 ·
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