From: normalperson@... Date: 2015-06-10T00:43:07+00:00 Subject: [ruby-core:69511] [Ruby trunk - Feature #11242] [Open] [PATCH] socket: alloa explicit buffer for recv and recv_nonblock Issue #11242 has been reported by Eric Wong. ---------------------------------------- Feature #11242: [PATCH] socket: alloa explicit buffer for recv and recv_nonblock https://bugs.ruby-lang.org/issues/11242 * Author: Eric Wong * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- --- Note, this relies on [Feature #11229] This reduces GC overhead and makes the API more consistent with IO#read and IO#read_nonblock. Benchmark results: user system total real alloc 0.130000 0.280000 0.410000 ( 0.420656) extbuf 0.100000 0.220000 0.320000 ( 0.318708) ------------------------8<----------------------- require 'socket' require 'benchmark' nr = 100000 msg = ' ' * 16384 size = msg.bytesize buf = ' ' * size UNIXSocket.pair(:DGRAM) do |a, b| Benchmark.bmbm do |x| x.report('alloc') do nr.times do b.send(msg, 0) a.recv(size, 0) end end x.report('extbuf') do nr.times do b.send(msg, 0) a.recv(size, 0, buf) end end end end --- ---Files-------------------------------- 0001-socket-allow-explicit-buffer-for-recv-and-recv_nonbl.patch (7.45 KB) -- https://bugs.ruby-lang.org/