|
Boost : |
From: Max Motovilov (max_at_[hidden])
Date: 2004-03-02 14:17:37
"Jeff Flinn" <TriumphSprint2000_at_[hidden]> wrote in message
news:c22in1$god$1_at_sea.gmane.org...
> This topic has come up on the spirit list. Originally I was a proponent of
> mmap approach based on experiencing major performance improvements with
> earlier version of Windows particularly Windows CE. Today I've seen much
> less difference in performance. I've been told that Windows 2K/Xp using
NTFS
> memorymaps files under the covers, and unless your actively adressing into
> the memory range there's little to be gained, atleast on Windows. Perhaps
> other os do this as well?
This is an issue that I have researched before. I have compared the
performance of Win32 memory mapped file API, synchronous file I/O API along
with iostreams and C-style buffered I/O (stdio.h). Still have the benchmark
prog but it uses a few library classes of my own so if I'd try to post
enough of the source here so it can be built and run, it'll be rather
unwieldy. It used fairly large I/O buffers (16K) to maximize throughput and
tested both sequential and random reading and writing performance. Actually,
I even had a provision to test file creation as opposed to writing to an
already allocated space since it might have put mapped files at a
disadvantage.
The summary of multiple runs is on the attached chart. The chart is in
logarithmic scale so actual numbers should be irrelevant. To provide a
reference point, the test was run on a Xeon 1.7G x 2 machine with 2G RDRAM
under Win.2003 Server and allocated the file on an NTFS-formatted 7200 RPM
IDE drive connected to a non-RAID (and, as far as I can tell, non-cached)
onboard IDE adapter. Typical run times for a 256M test file are 0.3-0.5 sec
using memory mapped files, 0.5-0.6 sec using file I/O (I'm not even gonna
mention iostreams and stdio here, you'll see how atrocious they are from the
chart).
Short version - memory mapped files are SO much faster, it is not even
funny. I did not go the extra mile and test the asynchronous I/O
(scatter/gather reads and writes); my expectation is that they should beat
memory mapping but not by much. There apparently is a good reason to listen
to the old Microsoft's recommendation and use memory mapping of files where
possible.
...Max...
begin 666 IOBenchmark.pdf
M)5!$1BTQ+C(*)<#(S-(-"C$@,"!O8FH*/#P*+U1I=&QE("A)3T)E;F-H;6%R
M:RYX;',I"B]!=71H;W(@*$UA>"D*+T-R96%T;W(@*'!D9D9A8W1O<GD@=W=W
M+G!D9F9A8W1O<GDN8V]M*0HO4')O9'5C97(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+U-U8G1Y<&4@+U1R=654>7!E"B].86UE("]&,0HO0F%S
M949O;G0@+T%R:6%L"B]&:7)S=$-H87(@,S(*+TQA<W1#:&%R(#(U-0HO5VED
M=&AS(%LR-S@@,C<X(#,U-2 U-38_at_-34V(#@X.2 V-C<@,3DQ(#,S,R S,S,@
M,S_at_Y(#4X-" R-S@@,S,S(#(W." R-S@*-34V(#4U-B U-38_at_-34V(#4U-B U
M-38_at_-34V(#4U-B U-38_at_-34V(#(W." R-S@@-3_at_T(#4X-" U.#0_at_-34V"C$P
M,34_at_-C8W(#8V-R W,C(@-S(R(#8V-R V,3$@-S<X(#<R,B R-S@@-3 P(#8V
M-R U-38_at_.#,S(#<R,B W-S@*-C8W(#<W." W,C(@-C8W(#8Q,2 W,C(@-C8W
M(#DT-" V-C<@-C8W(#8Q,2 R-S@@,C<X(#(W." T-CD_at_-34V"C,S,R U-38@
M-34V(#4P," U-38_at_-34V(#(W." U-38_at_-34V(#(R,B R,C(@-3 P(#(R,B X
M,S,@-34V(#4U-_at_HU-38@-34V(#,S,R U,# @,C<X(#4U-B U,# @-S(R(#4P
M," U,# @-3 P(#,S-" R-C @,S,T(#4X-" W-3 *.#8U(#4T,B R,C(@,S8U
M(#,S,R Q,# P(#4U-B U-38_at_-34V(#$P,# @,3 U-R S,S,@,3 Q," U.#,@
M.#4T(#<Q.0HU-38@,C(R(#(R,B S,S,@,S,S(#,U," U-38@,3 P," W-3 @
M,3 P," Y,#8@,S,S(#@Q,R T,S@@-34V(#4U,@HR-S@@-C,U(#4P," U,# @
M-34V(#0X.2 R-C @-34V(#8V-R W,S<@-S$Y(#4U-B U.#0@,S,S(#<S-R R
M-S@*-# P(#4T.2 R-S@@,C(R(#0Q,2 U-S8_at_-3,W(#(W." U-38@,3 W,R U
M,3 @-34V(#(R,B V-C<@-3 P(#(W. HV-C<@-C4V(#8V-R U-#(@-C<W(#8V
M-R Y,C,@-C T(#<Q.2 W,3D_at_-3@S(#8U-B X,S,@-S(R(#<W." W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P,# P,# U.30Y(# P,# P(&X-"G1R86EL
M97(*/#P*+U-I>F4@,3 *+TEN9F\@,2 P(%(*+U)O;W0@,B P(%(*+TE$(%L\
M.3%&049!-$0P-T,X1C%%-C4V0S!".$$Q-T)!0C9&,3,^/#DQ1D%&031$,#=#
M.$8Q138U-D,P0CA!,3="04(V1C$S/ET*/CX*<W1A<G1X<F5F"C4Y.34*)25%
#3T8*
`
end
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk