Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Using ":raw" layer in open() vs. calling binmode()

by jdalbec (Deacon)
on Jun 14, 2007 at 23:30 UTC ( [id://621364]=note: print w/replies, xml ) Need Help??


in reply to Using ":raw" layer in open() vs. calling binmode()

I don't have Perl on Windows, so I can't check whether all binary characters are read correctly, but I can confirm that on Mac OS X 10.4.9 Perl 5.8.6 <:raw:perlio does not lose buffering. I copied the PerlIO benchmark you referenced and added raw:perlio. The results are below.
#### Testing for 1 KB Read Benchmark: running mmap, nolayer, perlio, raw, raw:perlio for at least + 3 CPU seconds... mmap: 29 wallclock secs ( 1.21 usr + 2.00 sys = 3.21 CPU) @ 89 +4.70/s (n=2872) nolayer: 56 wallclock secs ( 1.52 usr + 1.67 sys = 3.19 CPU) @ 16 +57.05/s (n=5286) perlio: 41 wallclock secs ( 1.58 usr + 1.53 sys = 3.11 CPU) @ 14 +14.79/s (n=4400) raw: 7 wallclock secs ( 0.66 usr + 2.57 sys = 3.23 CPU) @ 12 +8.79/s (n=416) raw:perlio: 51 wallclock secs ( 1.52 usr + 1.60 sys = 3.12 CPU) @ 15 +43.59/s (n=4816) Rate raw mmap perlio raw:perlio nolay +er raw 129/s -- -86% -91% -92% -9 +2% mmap 895/s 595% -- -37% -42% -4 +6% perlio 1415/s 999% 58% -- -8% -1 +5% raw:perlio 1544/s 1099% 73% 9% -- - +7% nolayer 1657/s 1187% 85% 17% 7% +-- #### Testing for 4 KB Read Benchmark: running mmap, nolayer, perlio, raw, raw:perlio for at least + 3 CPU seconds... mmap: 28 wallclock secs ( 1.48 usr + 1.77 sys = 3.25 CPU) @ 84 +2.77/s (n=2739) nolayer: 44 wallclock secs ( 1.66 usr + 1.39 sys = 3.05 CPU) @ 13 +60.66/s (n=4150) perlio: 37 wallclock secs ( 1.81 usr + 1.37 sys = 3.18 CPU) @ 11 +85.53/s (n=3770) raw: 5 wallclock secs ( 0.61 usr + 2.57 sys = 3.18 CPU) @ 33 +.96/s (n=108) raw:perlio: 41 wallclock secs ( 1.78 usr + 1.42 sys = 3.20 CPU) @ 12 +79.38/s (n=4094) Rate raw mmap perlio raw:perlio nolay +er raw 34.0/s -- -96% -97% -97% -9 +8% mmap 843/s 2381% -- -29% -34% -3 +8% perlio 1186/s 3391% 41% -- -7% -1 +3% raw:perlio 1279/s 3667% 52% 8% -- - +6% nolayer 1361/s 3906% 61% 15% 6% +-- #### Testing for 16 KB Read Benchmark: running mmap, nolayer, perlio, raw, raw:perlio for at least + 3 CPU seconds... mmap: 19 wallclock secs ( 1.71 usr + 1.30 sys = 3.01 CPU) @ 52 +6.25/s (n=1584) nolayer: 26 wallclock secs ( 2.11 usr + 1.07 sys = 3.18 CPU) @ 77 +6.73/s (n=2470) perlio: 25 wallclock secs ( 2.17 usr + 1.04 sys = 3.21 CPU) @ 69 +3.15/s (n=2225) raw: 4 wallclock secs ( 0.57 usr + 2.46 sys = 3.03 CPU) @ 8 +.58/s (n=26) raw:perlio: 27 wallclock secs ( 2.14 usr + 1.04 sys = 3.18 CPU) @ 73 +3.96/s (n=2334) Rate raw mmap perlio raw:perlio nolay +er raw 8.58/s -- -98% -99% -99% -9 +9% mmap 526/s 6033% -- -24% -28% -3 +2% perlio 693/s 7978% 32% -- -6% -1 +1% raw:perlio 734/s 8453% 39% 6% -- - +6% nolayer 777/s 8952% 48% 12% 6% +-- #### Testing for 64 KB Read Benchmark: running mmap, nolayer, perlio, raw, raw:perlio for at least + 3 CPU seconds... mmap: 12 wallclock secs ( 2.46 usr + 0.78 sys = 3.24 CPU) @ 24 +1.36/s (n=782) nolayer: 14 wallclock secs ( 2.44 usr + 0.69 sys = 3.13 CPU) @ 29 +5.85/s (n=926) perlio: 12 wallclock secs ( 2.41 usr + 0.67 sys = 3.08 CPU) @ 26 +8.18/s (n=826) raw: 5 wallclock secs ( 0.60 usr + 2.64 sys = 3.24 CPU) @ 2 +.16/s (n=7) raw:perlio: 13 wallclock secs ( 2.39 usr + 0.65 sys = 3.04 CPU) @ 28 +1.25/s (n=855) Rate raw mmap perlio raw:perlio nolay +er raw 2.16/s -- -99% -99% -99% -9 +9% mmap 241/s 11071% -- -10% -14% -1 +8% perlio 268/s 12313% 11% -- -5% - +9% raw:perlio 281/s 12918% 17% 5% -- - +5% nolayer 296/s 13593% 23% 10% 5% +-- #### Testing for 256 KB Read Benchmark: running mmap, nolayer, perlio, raw, raw:perlio for at least + 3 CPU seconds... mmap: 6 wallclock secs ( 2.61 usr + 0.39 sys = 3.00 CPU) @ 76 +.67/s (n=230) nolayer: 7 wallclock secs ( 2.61 usr + 0.52 sys = 3.13 CPU) @ 85 +.30/s (n=267) perlio: 7 wallclock secs ( 2.71 usr + 0.52 sys = 3.23 CPU) @ 76 +.16/s (n=246) raw: 4 wallclock secs ( 0.71 usr + 3.05 sys = 3.76 CPU) @ 0 +.53/s (n=2) (warning: too few iterations for a reliable count) raw:perlio: 7 wallclock secs ( 2.72 usr + 0.51 sys = 3.23 CPU) @ 78 +.64/s (n=254) Rate raw perlio mmap raw:perlio nola +yer raw 0.532/s -- -99% -99% -99% - +99% perlio 76.2/s 14218% -- -1% -3% - +11% mmap 76.7/s 14313% 1% -- -3% - +10% raw:perlio 78.6/s 14684% 3% 3% -- +-8% nolayer 85.3/s 15937% 12% 11% 8% + --

Replies are listed 'Best First'.
Re^2: Using ":raw" layer in open() vs. calling binmode()
by Anonymous Monk on Jun 15, 2007 at 15:43 UTC

    Thanks for testing !

    Yes, if you explicitly specify the :perlio (or on MacOS maybe better :stdio) layer the stream will be buffered. What I don't understand (yet ?) is why a simple :raw removes all layers, including the existing :perlio (or in your case :stdio) layer.

    But I have the feeling, that that behaviour may be intentional and that only the documentation is a bit misleading here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://621364]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found