1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
Commit graph

23 commits

Author SHA1 Message Date
Evan Phoenix
0d8f026172 Don't allow any exceptions to terminate a thread 2015-06-10 11:52:09 -07:00
Ole Michaelis
5e95791cca Add thread reaping to thread pool 2015-05-20 14:57:40 +02:00
Emanuel Rietveld
f56ed3c4b8 Oops! These changes should not have been committed to the pull request. 2015-01-20 14:23:22 +01:00
Emanuel Rietveld
b784cb7f18 Add a configuration option that prevents puma from queueing requests.
With queue_requests set to true (the default), workers accept all
requests and queue them before passing them to the handlers.
With it set to false, each worker process accepts exactly as
many requests as it is configured to simultaneously handle.

In combination with threads 1, 1 this ensures that requests
are balanced across workers in a single threaded application.
This can avoid deadlocks when a single threaded app sends a
request to itself. (For example, to generate a PDF.)
2015-01-20 13:20:42 +01:00
Evan Phoenix
751720a3db Conditionalize thread local cleaning. Possible perf degradation fix 2014-11-25 23:18:30 -08:00
Evan Phoenix
26307307a2 Merge pull request #566 from sheltond/master
Added on_worker_shutdown mechanism
2014-11-23 19:39:27 -08:00
Daniel Neighman
a3aac917f6 Clean out a threads local data before doing work 2014-10-30 17:52:37 -07:00
Daniel Shelton
91f12ee279 Merge remote-tracking branch 'upstream/master' 2014-09-29 11:12:26 +01:00
Shannon Skipper
3896e2aa12 Fix thread spawning edge case.
Rapidly adding work to the ThreadPool can result in many jobs making it onto `@todo` before one of the jobs gets the mutex lock to decrement `@waiting`. So `@waiting == 0` isn't true and no thread is spawned even though there's work piling up, e.g.:

```ruby
require 'puma/thread_pool'

pool = Puma::ThreadPool.new(1, 3) { sleep 2 }

3.times { pool << 1 }

sleep 1

pool.spawned #=> 1 # When 3 is expected
```

Checking if `@waiting < @todo.size` shows that there's more work to do than threads waiting even if `@waiting` hasn't been decremented to `0` and also covers the base case where `@waiting == 0` and `@tudo.size == 1`.

An alternate option would be just adding the new check without removing the old one, something like `(@waiting == 0 or @waiting < @todo.size)`, but I don't think it's necessary unless for some kind of performance reason.
2014-08-19 22:36:34 -07:00
Daniel Shelton
df3f34e81c Fixed whitespace 2014-08-04 17:21:27 +01:00
Daniel Shelton
7f26f17e87 Cope with @workers being empty 2014-08-01 12:32:39 +01:00
Evan Phoenix
49e917a33d Process requests fairly. Fixes #406 2014-01-25 12:43:30 -08:00
Larry Marburger
26c961f1db Convert thread pool sizes to integers 2013-07-16 20:07:59 -04:00
Clint Shryock
26a1ab2e14 Standardize "block" usage
This commit standardizes on the use of `block` over `blk`. I found the usage of
both in the code.
2013-07-03 09:25:48 -05:00
Evan Phoenix
3726bc4f18 Be sure to empty the drain the todo before shutting down. Fixes #155 2012-10-12 23:05:23 -07:00
Evan Phoenix
ab8dbfeb96 Vastly improve IO perf on 1.9.3
Puma::IOBuffer is a very simple memory buffer that allows for fast
append without additional object overhead.

Additionally, turns out that IO#write on 1.9.3 is extremely
non-performant because it allows a Hash object on every invocation.
Avoid calling IO#write in a loop on 1.9.3! Use IO#syswrite if you can
(for instance when you don't care about the encoding of the output
(sockets)).
2012-08-11 15:09:09 -07:00
Evan Phoenix
6a90d64889 Fix bad test 2012-07-30 17:37:43 -06:00
Santiago Pastorino
fb4e23d628 Add missing localvars. Accessing localvars is faster than accessing ivars 2012-07-05 16:05:29 -03:00
Evan Phoenix
256970e048 Rearch how trimming takes place to not starve. Fixes #39
Using the work queue to communicate trimming doesn't work, it's far too
easy to starve the system doing that. Instead we now detect trimming and
work as seperate actions.
2012-02-07 09:49:23 -08:00
Evan Phoenix
6103e7f45b Add ability to use a config file (-C, --config) 2011-12-06 14:57:37 -08:00
Evan Phoenix
f11cd81470 Add automatic pool trimming 2011-12-05 10:07:01 -08:00
Evan Phoenix
b18cfae4b1 Write a bunch of documentation 2011-12-01 15:23:14 -08:00
Evan Phoenix
190a81c55a Name change: Mongrel => Puma 2011-09-22 19:24:43 -07:00
Renamed from lib/mongrel/thread_pool.rb (Browse further)