
Matthias Troyer wrote:
Suggestions ===========
a) Do more work in finding the speed bottlenecks. Run a profiler. Make a buffer based non-stream based archive and re-run your tests.
I have attached a benchmark for such an archive class and ran benchmarks for std::vector<char> serialization. Here are the numbers (using gcc-4 on a Powerbook G4):
I've take a look at your benchmark.cpp. First of all its very nice and simple and shows an understanding how the primitive i/o is isolated from the archives that use it. Its a step in the right direction. But I see some problems. The usage of std::vector<char> isn't what I would expect for an output buffer. You arn't using this in your own archives are you? Here are my timing results on my windoz XP system with a 2.4 gHz pentiem. With your original program I get for value_type set char Time using serialization library: 9.454 Size is 100000004 Time using direct calls to save in a loop: 8.844 Size is 100000000 Time using direct call to save_array: 0.266 Size is 100000000 for value type set to double Time using serialization library: 1.281 Size is 100000004 Time using direct calls to save in a loop: 1.218 Size is 100000000 Time using direct call to save_array: 0.266 Size is 100000000 I modified the to use a simple buffer output closer to what I would expect to use if I were going to make a primitive buffer output. BTW - that would be a very nice addition. This would be much faster than using strstream as is being use now. Here I the results with the program modified in this way For value type set to char I get Time using serialization library: 0.797 Size is 100000004 Time using direct calls to save in a loop: 0.297 (1) Size is 100000000 Time using direct call to save_array: 0.203 Size is 100000000 and for value_type set to double I get Time using serialization library: 0.109 (3) Size is 100000004 Time using direct calls to save in a loop: 0.078 (2) Size is 100000000 Time using direct call to save_array: 0.25 Size is 100000000 a) the usage of save_array does not have a huge effect on performance. It IS measureable. It seems that it saves about 1/3 the time over using a loop of saves in the best case. (1) b) In the worst case, its even slower than a loop of saves!!! (2) and even slower than the raw serialization system (3) c) the overhead of the serialization library isn't too bad. It does show up when doing 100M characters one by one, but generally it doesn't seem to be a big issuues. In my view, it does support my contention that implementing save_array - regardless of how it is in fact implemented - represents a premature optimization. I suspect that the net benefit in the kind of scenario you envision using it will be very small. Obviously, this test raises more questions than it answers and I think it should be persued further. Another thing I would like to see is a version of the test applied to C++ arrays. My interest is to isolate bottlenecks in the serialization library from those in the stl libraries. Robert Ramey begin 666 test_zmisc.cpp M(VEN8VQU9&4@/&-S=')I;F<^#0HC:6YC;'5D92 \8F]O<W0O87)C:&EV92]B M87-I8U]B:6YA<GE?;V%R8VAI=F4N:'!P/@T*(VEN8VQU9&4@/&EO<W1R96%M M/@T*(VEN8VQU9&4@/&)O;W-T+W1I;65R+FAP<#X-"B-I;F-L=61E(#QB;V]S M="]S97)I86QI>F%T:6]N+W9E8W1O<BYH<' ^#0H-"B-I9B Q#0IC;&%S<R!O M<')I;6ET:79E#0I[#0IP=6)L:6,Z#0H@(" @+R\@9&5F875L="!S879I;F<@ M;V8@<')I;6ET:79E<RX-"B @("!T96UP;&%T93QC;&%S<R!4/@T*(" @('9O M:60@<V%V92AC;VYS="!4("8@="D-"B @("![#0H@(" @(" @('-A=F5?8FEN M87)Y*"9T+"!S:7IE;V8H5"DI.PT*(" @('T-"@T*(" @("\O(&1E9F%U;'0@ M<V%V:6YG(&]F(&%R<F%Y<RX-"B @("!T96UP;&%T93QC;&%S<R!4/@T*(" @ M('9O:60@<V%V95]A<G)A>2AC;VYS="!4("H@<"P@<W1D.CIS:7IE7W0@;BD- M"B @("![#0H@(" @(" @('-A=F5?8FEN87)Y*' L(&XJ<VEZ96]F*%0I*3L- M"B @("!]#0H-"B @("!V;VED('-A=F4H8V]N<W0@<W1D.CIS=')I;F<@)G,I M('M]#0H-"B @("!V;VED('-A=F5?8FEN87)Y*&-O;G-T('9O:60@*F%D9')E M<W,L('-T9#HZ<VEZ95]T(&-O=6YT*0T*(" @('L-"B @(" @(&)U9F9E<BYI M;G-E<G0H8G5F9F5R+F5N9"@I+'-T871I8U]C87-T/&-O;G-T(&-H87(J/BAA M9&1R97-S*2P@<W1A=&EC7V-A<W0\8V]N<W0@8VAA<BH^*&%D9')E<W,I*V-O M=6YT*3L-"B @("!]#0H@(" @#0H@(" @<W1D.CIS:7IE7W0@<VEZ92@I('L@ M<F5T=7)N(&)U9F9E<BYS:7IE*"D[?0T*(" @('9O:60@<F5S97)V92AS=&0Z M.G-I>F5?="!N*2![(&)U9F9E<BYR97-E<G9E*&XI.WT-"G!R:79A=&4Z#0H@ M('-T9#HZ=F5C=&]R/&-H87(^(&)U9F9E<CL-"GT[#0H-"B-E;'-E#0H-"F-L M87-S(&]P<FEM:71I=F4-"GL-"G!U8FQI8SH-"B @(" O+R!D969A=6QT('-A M=FEN9R!O9B!P<FEM:71I=F5S+@T*(" @('1E;7!L871E/&-L87-S(%0^#0H@ M(" @=F]I9"!S879E*&-O;G-T(%0@)B!T*0T*(" @('L-"B @(" @(" @<V%V M95]B:6YA<GDH)G0L('-I>F5O9BA4*2D[#0H@(" @?0T*#0H@(" @+R\@9&5F M875L="!S879I;F<@;V8@87)R87ES+@T*(" @('1E;7!L871E/&-L87-S(%0^ M#0H@(" @=F]I9"!S879E7V%R<F%Y*&-O;G-T(%0@*B!P+"!S=&0Z.G-I>F5? M="!N*0T*(" @('L-"B @(" @(" @<V%V95]B:6YA<GDH<"P@;BIS:7IE;V8H M5"DI.PT*(" @('T-"@T*(" @('9O:60@<V%V92AC;VYS="!S=&0Z.G-T<FEN M9R F<RD@>WT-"@T*(" @('9O:60@<V%V95]B:6YA<GDH8V]N<W0@=F]I9" J M861D<F5S<RP@<W1D.CIS:7IE7W0@8V]U;G0I#0H@(" @>PT*(" @(" @("!S M=&0Z.FUE;6-P>2AB=69F97(L(&%D9')E<W,L(&-O=6YT*3L-"B @(" @(" @ M<" K/2!C;W5N=#L-"B @("!]#0H@(" @#0H@(" @<W1D.CIS:7IE7W0@<VEZ M92@I('L@<F5T=7)N(',[?0T*(" @('9O:60@<F5S97)V92AS=&0Z.G-I>F5? M="!N*7L-"B @(" @(" @<R ](&X[#0H@(" @(" @(' @/2 P.PT*(" @(" @ M("!B=69F97(@/2!N97<@8VAA<EMN73L-"B @("!]#0H@(" @?F]P<FEM:71I M=F4H*7L-"B @(" @(" @9&5L971E(&)U9F9E<CL-"B @("!]#0IP<FEV871E M.@T*(" @('-T9#HZ<VEZ95]T(',[#0H@(" @<W1D.CIS:7IE7W0@<#L-"B @ M("!C:&%R("H@8G5F9F5R.PT*?3L-"@T*(V5N9&EF#0H-"G1E;7!L871E/&-L M87-S($%R8VAI=F4^#0IC;&%S<R!O87)C:&EV95]I;7!L(#H@#0H@(" @<'5B M;&EC(&]P<FEM:71I=F4L#0H@(" @<'5B;&EC(&)O;W-T.CIA<F-H:79E.CIB M87-I8U]B:6YA<GE?;V%R8VAI=F4\07)C:&EV93X-"GL-"G!U8FQI8SH-"B @ M("!O87)C:&EV95]I;7!L*'5N<VEG;F5D(&EN="!F;&%G<RD@.@T*(" @(" @ M("!B;V]S=#HZ87)C:&EV93HZ8F%S:6-?8FEN87)Y7V]A<F-H:79E/$%R8VAI M=F4^*&9L86=S*0T*(" @('M]#0I].PT*#0IC;&%S<R!O87)C:&EV92 Z( T* M(" @('!U8FQI8R!O87)C:&EV95]I;7!L/&]A<F-H:79E/@T*>PT*<'5B;&EC M.@T*(" @(&]A<F-H:79E*'5N<VEG;F5D(&EN="!F;&%G<R ](# I(#H-"B @ M(" @(" @;V%R8VAI=F5?:6UP;#QO87)C:&EV93XH9FQA9W,I#0H@(" @>WT- M"GT[#0H-"FEN="!M86EN*"D-"GL@(" @#0H@('1Y<&5D968@8VAA<B!V86QU M95]T>7!E.PT*(" -"B @<W1D.CIS:7IE7W0@;G5M8F5R7V]F7V5L96UE;G1S M(#T@,3 P,# P,# P+W-I>F5O9BAV86QU95]T>7!E*3L-"B @8V]N<W0@<W1D M.CIV96-T;W(\=F%L=65?='EP93X@=BAN=6UB97)?;V9?96QE;65N=',I.PT* M#0H@('L-"B @("!O87)C:&EV92!A<CL-"B @("!A<BYR97-E<G9E*&YU;6)E M<E]O9E]E;&5M96YT<RIS:7IE;V8H=F%L=65?='EP92DK-"D[#0H@(" @8F]O M<W0Z.G1I;65R('1I;64[#0H@(" @87(@/#P@=CL-"B @("!S=&0Z.F-O=70@ M/#P@(E1I;64@=7-I;F<@<V5R:6%L:7IA=&EO;B!L:6)R87)Y.B B(#P\('1I M;64N96QA<'-E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