about summary refs log tree commit homepage
path: root/lib/yahns/wbuf.rb
DateCommit message (Collapse)
2019-01-05wbuf: use IO#write directly in Ruby 2.5+ for writev
Slowly removing kgio dependencies...
2016-07-19wbuf_lite: prevent clobbering responses
All of our wbuf code assumes we append to existing buffers (files) since sendfile cannot deal otherwise. We also follow this pattern for StringIO to avoid extra data copies.
2016-06-06wbuf: remove tmpdir parameter
We can retrieve it when we actually need to create the temporary file. This saves an ivar slot and method dispatch parameters. This patch is nice, unfortunately the patch which follows is not :P
2016-06-05wbuf: remove needless "busy" parameter
@busy will be reset on wbuf_write anyways, since there is no initial data and we will always attempt to write to the socket aggressively.
2016-06-05proxy_pass: redo "proxy_buffering: false"
Relying on @body.close in Yahns::WbufCommon#wbuf_close_common to resume reading the upstream response was too subtle and potentially racy. Instead use a new Yahns::WbufLite class which does exactly what we want for implementing this feature, and nothing more.
2016-06-03proxy_pass: support "proxy_buffering: false"
This may be useful to avoid wasting resources when proxying for an upstream which can already handle slow clients itself. It is impossible to completely disable buffering, this merely prevents gigantic amounts of buffering. This may be useful when an upstream can generate a gigantic response which would cause excessive disk I/O traffic if buffered by yahns. An example of this would be an upstream dynamically-generating a pack for a giant git (clone|fetch) operation. In other words, this option allows the upstream to react to backpressure from slow clients. It is not recommended to enable this unless your upstream server is capable of supporting slow clients.
2016-01-02copyright updates for 2016
Using the 'update-copyright' script from gnulib[1]: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright We're also switching to 'GPL-3.0+' as recommended by SPDX to be consistent with our gemspec and other metadata (as opposed to the longer but equivalent "GPLv3 or later"). [1] git://git.savannah.gnu.org/gnulib.git
2016-01-02enable frozen_string_literal for Ruby 2.3+
There are likely yet-to-be-discovered bugs in here. Also, keeping explicit #freeze calls for 2.2 users, since most users have not migrated to 2.3, yet.
2015-12-01wbuf: fix typo in bug check for sendfile gem
This typo would've only be triggered if the sendfile gem itself turns out to be buggy and returns an undocumented return code.
2015-04-07wbuf: fix writev calls for vectors
kgio_writev returns nil on success instead of the number of bytes written, so we must manually calculate the number of bytes written intead :x This is triggerable when sending giant chunked responses.
2015-04-03proxy_pass: rewrite to be async, using rack.hijack
This allows our reverse proxy to avoid having an innefficient 1:1 relationship between threads and upstream connections, reducing memory usage when there are many upstream connections (possibly to multiple backend machines).
2015-04-03allow vector args to wbuf_write
This allows us to write chunked response bodies without extra copying to clients which support streaming.
2015-04-03wbuf: store busy signal inside this object
This should make it easier to track state for asynchronous proxy_pass buffering.
2015-01-24wbuf: lazily (re)create temporary file
We may not need this temporary file if we've flushed everything out and entered bypass mode.
2014-07-16wbuf: avoid corrupted large responses with zero-copy sendfile
This bug is noticeable on a amd64 FreeBSD 9.2 VM, and possible under Linux, too. This happens as a zero-copy sendfile implementation means pages queued for transmission by the sendfile system call should not be modified at any point after the sendfile syscall is made. To prevent modification, we replace the temporary file with a new one. This has a similar effect as truncate and can still prevent a dirty flush in cases when a client consumes the response fast enough. This reverts the misguided ade89b5142bedbcf07f38aa062bfdbfcb8bc48d3 commit ("wbuf: hack to avoid response corruption on FreeBSD") Note: this bug was finally fixed because I finally noticed this flaw in a different (non-Ruby, non-HTTP) server of mine.
2014-03-15wbuf: hack to avoid response corruption on FreeBSD
This likely makes no difference in 99% of real world situations with fast response generation. The only case where lack of output buffer bypass makes a difference is when the following sequence happens: 1) a giant response cannot fit into socket buffers 2) temporary file created for buffering 3) client consumes output so we get more space in socket buffers 4) app response generation continues (streaming response) 5) we successfully write _all_ previously buffered data to socket 6) we may bypass buffering for data generated in step 4 So right now, we cannot do step 6 outside of Linux. Instead, once an output buffer is created; we must always write to the output buffers.
2013-11-06wbuf: document reasoning for the design of these clases
The choice to jump directly to temporary files on EAGAIN may seem odd to some, document our reasoning for choosing this approach.
2013-11-01input and output buffers support tmpdir: arguments
This allows users to specify alternative temporary directories in case buffers get too large for one filesystem to handle or to give priority to some clients on certain ports.
2013-11-01wbuf: only enable bypass if we've truncated
The first time we call wbuf_write, we do so because we already hit :wait_writable in the caller. So we can avoid the extra still-highly-likely-to-return-:wait_*) kgio_trywrite by writing to the VFS, first.
2013-11-01wbuf: reset FS (sendfile) buffer if caught up
This can prevent dirty data from being committed, saving the system from unnecessary disk activity.
2013-11-01wbuf: bypass buffering if buffers are caught up
Sometimes buffering can catch up and we no longer need to use the on-disk buffer, so keep trying to flush the data out to the user to avoid VFS activity.
2013-10-18initial commit