about summary refs log tree commit homepage
path: root/lib/rainbows
DateCommit message (Collapse)
2011-01-11event_machine: buffer reads when waiting for async.callback
We cannot trigger on_read events and invoke the HTTP parser and modify @env while we're waiting for an application to run async.callback. We also need to clear (and *maybe* re-set) @deferred if we're writing from async.callback
2011-01-11event_machine/client: rename ivar for consistency with Coolio
Both use @deferred to refer to the state where there's a deferred response body in the queue.
2011-01-11event_machine/client: remove unused :body accessor
Nobody uses it anymore
2011-01-11coolio: enable async.callback for one-shot body responses
The lack of an equivlent to EM::Deferrable prevents us from doing streaming/trickling responses, but a one-shot body should work fine for Coolio and generating dynamic responses.
2011-01-07rainbows/coolio/client: set LOOP constant in module
It's more natural and easier to maintain this way since Coolio::Client is always lazy loaded.
2011-01-07coolio/client: small optimizations
* lazy load uncommon classes: StreamFile, Response{Chunk,}Pipe * remove needless rainbows/coolio/sendfile module since we're lazily loaded now along with the rest of rainbows/coolio/client and only in the worker.
2011-01-07coolio_thread_*: lazy load Rainbows::Coolio::Client
We don't want that loaded in the parent process since we want config reloadability.
2011-01-07event_machine: fold write_response back into client
No point in having too many modules to search around (for both hackers and the runtime).
2011-01-07event_machine: cleanup async logic
Since we support keepalive now, setting @state can be harmful and the comment is out-of-date.
2011-01-07ev_core: small organization cleanup
We want to put all constants in one place.
2011-01-07more consistent use/avoidance of HeaderHash
Rack::Utils::HeaderHash is still expensive, so avoid forcing it on users since we can assume app/library authors use normally-cased HTTP headers.
2011-01-07favor Hash#include? for some existence checks
Hash#[] is slightly slower on the miss case due to calling Hash#default (but faster for the hit case, probably because it is inlined in 1.9).
2011-01-07response: do not skip Status header set by app
Rack::Lint already stops apps from using it. If a developer insists on it, then users who inspect their HTTP headers can point and laugh at them for not using Rack::Lint!
2011-01-07response: fix skipping of Status: header from app
We already set a Status: header by default for compatibility with some existing, broken libraries out there.
2011-01-07ev_core: garbage reduction with const strings
Reading headers is common and we don't want to create new String objects (even if they're tiny or copy-on-write) for the GC to munch on.
2011-01-06event_machine: refactor async.callback for keepalive
async.callback will be useful with Coolio (and more!) soon, so ensure it works as well as the rest of Rainbows!
2011-01-06event_machine: factor out async.callback handling
This will allow Coolio to use it, too.
2011-01-06minor cleanups following state cleanups
We noticed a few more things that could be cleaned up after the last commit.
2011-01-06eliminate G constant and just use the Rainbows! module
Code organization is hard :<
2011-01-06eliminate timed_read module
No need to split it out when there's only a single class using it.
2011-01-06simplify keepalive_timeout accounting
Easier just to use an instance variable
2011-01-05response: use optimized httpdate implementation
Believe it or not, Time#httpdate showed up at the top of my profiler output for the past couple of years now. I guess that's what happens when all HTTP applications I write are less complex than Rack::Lobster :P
2011-01-05response: allow normal Hash for crafting Range headers
HeaderHash is quite expensive, and Rack::File currently uses a regular Ruby Hash with properly-cased headers the same way they're presented in rfc2616.
2011-01-05send proper 416 responses
416 responses without a body should respond with a zero Content-Length and a Content-Range that allows clients to specify a proper range in the future. rfc2616, section 14.16 says: > A server sending a response with status code 416 (Requested > range not satisfiable) SHOULD include a Content-Range field > with a byte-range- resp-spec of "*". The instance-length > specifies the current length of the selected resource.
2011-01-04writer_thread_pool: remove unnecesary debug messages
Oops
2011-01-04prefer Hash#merge! to Hash#update for consistency
It's more likely to be in the method cache since Rack::URLMap uses it and also is more consistent when looking at profiling output against various concurrency models.
2011-01-04globally refactor Range handling for responses
Rack::Utils::HeaderHash is still very expensive in Rack 1.2, especially for simple things that we want to run as fast as possible with minimal interference. HeaderHash is unnecessary for most requests that do not send Content-Range in responses.
2011-01-04coolio: rename deferred_response => response_pipe
For consistency with the EventMachine code
2011-01-04event_machine: cleanup response_pipe
No need to pass unnecessary variables to response_pipe, just let the client handle it all.
2011-01-04refactor response sendfile body handling for easier debugging
Unique method names makes it easier to follow code and determine where our methods come from.
2011-01-04simplify per-client keepalive state checks
This lets us simplify repetitive checks worry less about properly maintaining/closing client connections for each concurrency model we support.
2011-01-04coolio/master: small garbage reduction
Creating unnecessary string objects for every response is not a good idea.
2011-01-04return 206 status for partial sendfile responses
Although curl did not complain, 206 is the correct error code for partial HTTP responses.
2011-01-04coolio_thread_*: fix 416 response handling
After beefing up and enabling byte range tests for "sendfile" (and no just IO.copy_stream), we noticed threaded-Coolio variants did not handle invalid byte ranges correctly.
2010-12-29Rainbows! 2.1.0 - Cool.io, bugfixes and more!
Cool.io (new version of Rev) support is explicitly added (it always worked before). ":Coolio" may be used in place of ":Rev" anywhere in your Rainbows! config file. There is a new "keepalive_requests" config directive to limit the number of requests a single connection may make (default: 100, same as nginx). This may be useful for better load-balancing characteristics. The old "Rev" prefixes remain supported as long as Cool.io remains compatible with Rev (likely forever). Bug fixes: * Rainbows::ThreadTimeout middleware with multiple clients * large, pipelined upload errors with Revactor+Coolio(Rev) * high CPU usage for maintaining idle keepalive on *Fiber* * needless ThreadPool wakeups * request env prematurely cleared keepalive requests, breaking some middlewares such as Clogger. * "close" not called on body if wrapper and sendfile used together Various code cleanups, and our RDoc website is JavaScript-free. See the ChangeLog or git for all changes.
2010-12-28complete Rev => Coolio renaming
We use Cool.io internally everywhere now, but preserve Rev-based models for anybody using them.
2010-12-28several response body#close fixes
Some middlewares require the Rack env to be preserved all the way through to close, so we'll ensure all request models preserve it. We also need to better response body wrappers/proxies always get fired properly when returning. IO.copy_stream and "sendfile" gem users could hit cases where wrappers did not fire properly.
2010-12-28dev_fd_response: pass files straight through
No need to wrap regular files
2010-12-28enable the keepalive_requests config option
This will allow servers to limit the number of keepalive requests that can be made over a single connection to prevent denial-of-service and also to improve fairness in load-balancing.
2010-12-27coolio*: favor Coolio over Rev
We still use and define Rev internally, but that's mostly just manual labor of converting stuff over.
2010-12-27coolio_fiber_spawn: decrease CPU usage for keepalive
Blindly resuming fibers every second is a waste of cycles, we can use the ZZ hash in regular FiberSpawn to resume expired fibers on an as-needed basis. While we're at it, merge the keepalive-timeout class into the heartbeat, there's no reason to have separate timers and classes here.
2010-12-27doc: misc cleanups and additions for RDoc
This is also our website, so we need to document the new Cool.io-based concurrency options for users and point existing Rev* users to it.
2010-12-27initial cool.io support
Cool.io is the new name for Rev. We'll continue to support Rev until Cool.io breaks backwards compatibility. Rev may not be supported if Cool.io is.
2010-12-27fiber/io: avoid allocating Range objects for slicing
It's slightly faster this way, but string slicing sucks anyways :<
2010-12-27fiber/*: more efficient keepalive_timeout expiry
We can use the same interface as Rainbows::Fiber.sleep to avoid blindly waking up readers at ever scheduler invocation.
2010-12-27fiber/base: use bare "select" where possible
Less visual noise
2010-12-27thread_pool: avoid needless wakeups from select
No point in waking up when our ticker runs in a separate thread.
2010-12-27thread_*: unindent
Hopefully this will make our code easier to follow.
2010-12-27introduce worker_yield method
This lets Rainbows! yield the current worker process when busy in the hopes another worker will pick up the slack. We can also override this for the single worker process case later if people care enough.
2010-12-27writer_thread_spawn: factor out Client.quit
Self-documenting code is easier to follow