From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AE66B202A5 for ; Tue, 26 Sep 2017 00:55:09 +0000 (UTC) Date: Tue, 26 Sep 2017 00:55:09 +0000 From: Eric Wong To: spew@80x24.org Subject: Re: [PATCH 0/3] implement IO.writev method Message-ID: <20170926005509.GA22313@starla> References: <1268452495-26406-1-git-send-email-normalperson@yhbt.net> <1268452495-26406-2-git-send-email-normalperson@yhbt.net> <20100313040220.GA26654@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20100313040220.GA26654@dcvr.yhbt.net> List-Id: > The following series implements IO.writev as a wrapper for the > writev(2) system call. > > IO.writev can be used to efficiently write an array of strings > atomically without the need to create a temporary string via Array#join > or repeatedly make expensive method/system calls. > > Benchmark results (see script below): > > Rehearsal -------------------------------------------- > syswrite 16.950000 2.010000 18.960000 ( 19.023356) > writev 7.420000 2.480000 9.900000 ( 9.903122) > ---------------------------------- total: 28.860000sec > > user system total real > syswrite 16.930000 1.940000 18.870000 ( 18.906436) > writev 7.120000 2.760000 9.880000 ( 9.905839) > > If everything looks OK, you may pull here: > git://git.bogomips.org/io-extra.git > > or browse cgit here: > http://git.bogomips.org/cgit/io-extra.git > > ----------------------------- 8< ------------------------------ > # -*- encoding: binary -*- > require 'benchmark' > require 'io/extra' > > # writev wins by larger margins as buffers get larger or iovcnt increases > nr = 10000000 > buf = '.' * 25 > iovcnt = 3 > vec = iovcnt.times.map { buf } > > null = File.open("/dev/null", "wb") > null.sync = true > Benchmark.bmbm do |x| > x.report("syswrite") do > nr.times { null.syswrite(vec.join("")) } > end > x.report("writev") do > nr.times { IO.writev(null.fileno, vec) } > end > end > ----------------------------- 8< ------------------------------