Thread pools behaving oddly with `max_queue` and `remaining_capacity`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start with the ThreadPoolExecutor configuration and the reported entry point in lib/concurrent/executor/ruby_executor_service.rb, then inspect the synchronization paths in lib/concurrent/synchronization/mri_lockable_object.rb and related executor code. Reproduce the script and compare max_queue, remaining_capacity, rejection, and wait_for_termination behavior with the documented expectations; done means the intended behavior is established and covered by an appropriate test or documentation update.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
We're in need for a thread pool that has a maximum number of parallel threads, no queue and fails if too many threads are added. We also need to be able to detect how many threads are "free" at a given time.
We've tried almost all of the ThreadPool and ThreadPoolExecutor classes but can't get it to work:
require 'concurrent'
pool = Concurrent::ThreadPoolExecutor.new(
min_threads: 0,
max_threads: 5,
max_queue: 0,
fallback_policy: :abort,
auto_terminate: false
)
6.times do
pool.post { sleep 5 }
puts pool.remaining_capacity
end
pool.wait_for_termination
If we interpret the documentation right, this should create a thread pool with 0 threads at start that can grow up to 5 threads which are handled in parallel. If all 5 threads are occupied, posting new work units should result in an exception. There should be no additional queue. We'd also expect remaining_capacity to drop by 1 each time something has been posted and the previous threads are still busy.
The output of the above script:
-1
-1
-1
-1
-1
-1
Expected would be:
4
3
2
1
0
=> EXCEPTION
Did we interpret the documentation wrong and how can we achieve what we need? We're also need to be able to detect the number of idle threads so that we can post the right number of work units to it.
On a side-note: The above example stops with a number of exceptions like the following:
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:43:in `sleep': No live threads left. Deadlock? (fatal)
6 threads, 6 sleeps current:0x00007fa6936e27d0 main thread:0x00007fa6937044c0
* #<Thread:0x00007fa69487f0b8 sleep_forever>
rb_thread_t:0x00007fa6937044c0 native:0x00007fff7b53e000 int:1
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:43:in `sleep'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:43:in `wait'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:43:in `ns_wait'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/abstract_lockable_object.rb:43:in `ns_wait_until'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/event.rb:87:in `block in wait'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `block in synchronize'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/event.rb:84:in `wait'
/usr/local/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_executor_service.rb:49:in `wait_for_termination'
concurrent_test.rb:16:in `<main>'
I have currently no idea what this is about. But this second problem does not happen in our application and is not a dealbreaker.
Thanks a bunch for having a look at the first question though - this would help us a lot. Keep up your wonderful work!
- Operating system: mac
concurrent-rubyversion: 1.0.5concurrent-ruby-extinstalled: noconcurrent-ruby-edgeused: no
- Lenguaje dominante
- Ruby
- Estrellas
- 5.8k
- Forks
- 420
- Merge medio
- 20 h 45 min
- PR fusionados (30 d)
- 4
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.
Más de ruby-concurrency/concurrent-ruby
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
ruby-concurrency/concurrent-ruby#1118 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
ruby-concurrency/concurrent-ruby#1099 · 9 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
ruby-concurrency/concurrent-ruby#1095 · 8 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
ruby-concurrency/concurrent-ruby#1093 · 3 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
ruby-concurrency/concurrent-ruby#1091 ·
Todos los issues de ruby-concurrency/concurrent-ruby
Issues similares
-
バグ
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
Version bump for OpenVox 9 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
voxpupuli/puppet-epel#186 · 1 comentario ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) AbiertoBug Frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
TheOdinProject/curriculum#31402 · 1 comentario ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100