diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-12-27 08:08:50 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-12-27 08:08:50 +0000 |
commit | df634904b60f0aa17a99afd225c58a7605c9ee37 (patch) | |
tree | 7c47f8d870a8dc17345f29393f4158298b48e640 /lib/dtas/buffer/splice.rb | |
parent | dc89cfd111eff569bac3077b366c5ed8737d05a5 (diff) | |
download | dtas-df634904b60f0aa17a99afd225c58a7605c9ee37.tar.gz |
Avoid an additional select syscall in the splice path by injecting the target checks into the main loop. We can do this because we always process writers before readers. This adds additional userspace processing, but it avoids one potentially expensive (and potentially task-switching) syscall in many cases; so it should be worth it to avoid skipping with small buffer. This should avoid buffer underuns with mixed-sized buffers when using multiple sinks. This could work for the read_write path, too, but I don't use that enough and this change may still be buggy even for splice users.
Diffstat (limited to 'lib/dtas/buffer/splice.rb')
-rw-r--r-- | lib/dtas/buffer/splice.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dtas/buffer/splice.rb b/lib/dtas/buffer/splice.rb index 9093860..2a7e9a4 100644 --- a/lib/dtas/buffer/splice.rb +++ b/lib/dtas/buffer/splice.rb @@ -69,7 +69,9 @@ module DTAS::Buffer::Splice # :nodoc: end def broadcast_inf(targets) - if targets.none?(&:nonblock?) + if targets.all?(&:ready_write_optimized?) + blocked = [] + elsif targets.none?(&:nonblock?) # if all targets are blocking, don't start until they're all writable r = IO.select(nil, targets, nil, 0) or return targets blocked = targets - r[1] |