-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change usage of std::string to movable object #144
Comments
Thanks for pointing out @olzhabay. I totally get your point, however, in many sections of the code whenever expensive string assignment was done I forced the move using |
It does not move if |
What if we make the data wrapper class serializable like this for now? Maybe later on, the implementation of raw block sending can be implemented. |
I have reviewed the proposed I also understand the rationale of the proposed idea, you find
|
@vicentebolea got it. Proceeding with tests and benchmarks to see the actual performance benefits |
Performance benchmark resultstested two cases:
std::string performance
slice performance
|
Hey the numbers are too high.
Did you drop the buffer cache before the benchmarks?
…On Fri, Oct 12, 2018, 19:53 Olzhas Kaiyrakhmet ***@***.***> wrote:
std::string performance
----------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
----------------------------------------------------------------------------
BM_creation/8 34 ns 34 ns 20388586 bytes_per_second=222.224M/s
BM_creation/64 61 ns 61 ns 11668637 bytes_per_second=1008.09M/s
BM_creation/512 113 ns 113 ns 6118007 bytes_per_second=4.20737G/s
BM_creation/1024 142 ns 142 ns 4906628 bytes_per_second=6.72681G/s
BM_creation/8192 362 ns 362 ns 1933918 bytes_per_second=21.091G/s
BM_creation/67108864 20001119 ns 19945407 ns 33 bytes_per_second=3.13355G/s
BM_move/8 1 ns 1 ns 626554280 bytes_per_second=6.68698G/s
BM_move/64 1 ns 1 ns 626517599 bytes_per_second=53.4915G/s
BM_move/512 1 ns 1 ns 627175796 bytes_per_second=427.968G/s
BM_move/1024 1 ns 1 ns 627080058 bytes_per_second=855.979G/s
BM_move/8192 1 ns 1 ns 626729370 bytes_per_second=6.68706T/s
BM_move/67108864 1 ns 1 ns 627153977 bytes_per_second=53.4822P/s
slice performance
----------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
----------------------------------------------------------------------------
BM_creation/8 31 ns 31 ns 22385795 bytes_per_second=245M/s
BM_creation/64 31 ns 31 ns 22250523 bytes_per_second=1.90128G/s
BM_creation/512 44 ns 44 ns 16038834 bytes_per_second=10.8969G/s
BM_creation/1024 48 ns 48 ns 14534327 bytes_per_second=19.8019G/s
BM_creation/8192 139 ns 139 ns 4993379 bytes_per_second=54.8901G/s
BM_creation/67108864 6466286 ns 6466127 ns 89 bytes_per_second=9.66575G/s
BM_move/8 0 ns 0 ns 1000000000 bytes_per_second=31.5797P/s
BM_move/64 0 ns 0 ns 1000000000 bytes_per_second=260.75P/s
BM_move/512 0 ns 0 ns 1000000000 bytes_per_second=2.0278E/s
BM_move/1024 0 ns 0 ns 1000000000 bytes_per_second=4.05561E/s
BM_move/8192 0 ns 0 ns 1000000000 bytes_per_second=32.5937E/s
BM_move/67108864 0 ns 0 ns 1000000000 bytes_per_second=72.9697Z/s
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#144 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA5XFncphW-11LhSEE32roPVETT-aXmrks5ukHSfgaJpZM4XJs1O>
.
|
You must have a future computer to have petabytes per second throughout haha
On Fri, Oct 12, 2018, 21:35 Vicente Adolfo Bolea Sánchez <
vicente.bolea@gmail.com> wrote:
… Hey the numbers are too high.
Did you drop the buffer cache before the benchmarks?
On Fri, Oct 12, 2018, 19:53 Olzhas Kaiyrakhmet ***@***.***>
wrote:
> std::string performance
>
> ----------------------------------------------------------------------------
> Benchmark Time CPU Iterations UserCounters...
> ----------------------------------------------------------------------------
> BM_creation/8 34 ns 34 ns 20388586 bytes_per_second=222.224M/s
> BM_creation/64 61 ns 61 ns 11668637 bytes_per_second=1008.09M/s
> BM_creation/512 113 ns 113 ns 6118007 bytes_per_second=4.20737G/s
> BM_creation/1024 142 ns 142 ns 4906628 bytes_per_second=6.72681G/s
> BM_creation/8192 362 ns 362 ns 1933918 bytes_per_second=21.091G/s
> BM_creation/67108864 20001119 ns 19945407 ns 33 bytes_per_second=3.13355G/s
> BM_move/8 1 ns 1 ns 626554280 bytes_per_second=6.68698G/s
> BM_move/64 1 ns 1 ns 626517599 bytes_per_second=53.4915G/s
> BM_move/512 1 ns 1 ns 627175796 bytes_per_second=427.968G/s
> BM_move/1024 1 ns 1 ns 627080058 bytes_per_second=855.979G/s
> BM_move/8192 1 ns 1 ns 626729370 bytes_per_second=6.68706T/s
> BM_move/67108864 1 ns 1 ns 627153977 bytes_per_second=53.4822P/s
>
> slice performance
>
> ----------------------------------------------------------------------------
> Benchmark Time CPU Iterations UserCounters...
> ----------------------------------------------------------------------------
> BM_creation/8 31 ns 31 ns 22385795 bytes_per_second=245M/s
> BM_creation/64 31 ns 31 ns 22250523 bytes_per_second=1.90128G/s
> BM_creation/512 44 ns 44 ns 16038834 bytes_per_second=10.8969G/s
> BM_creation/1024 48 ns 48 ns 14534327 bytes_per_second=19.8019G/s
> BM_creation/8192 139 ns 139 ns 4993379 bytes_per_second=54.8901G/s
> BM_creation/67108864 6466286 ns 6466127 ns 89 bytes_per_second=9.66575G/s
> BM_move/8 0 ns 0 ns 1000000000 bytes_per_second=31.5797P/s
> BM_move/64 0 ns 0 ns 1000000000 bytes_per_second=260.75P/s
> BM_move/512 0 ns 0 ns 1000000000 bytes_per_second=2.0278E/s
> BM_move/1024 0 ns 0 ns 1000000000 bytes_per_second=4.05561E/s
> BM_move/8192 0 ns 0 ns 1000000000 bytes_per_second=32.5937E/s
> BM_move/67108864 0 ns 0 ns 1000000000 bytes_per_second=72.9697Z/s
>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#144 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AA5XFncphW-11LhSEE32roPVETT-aXmrks5ukHSfgaJpZM4XJs1O>
> .
>
|
Update on performance benchmark resultsHere are again comparison of
Results for std::string
Results for slice
We can see significant result performance improvement on 64MB data serialization/deserialization |
@olzhabay, you are doing a very fine job benchmarking this one. it looks like serialization exec time for str is linearly proportional to its size.
For slice it just takes a bit more exec time from 8 KB to 64MB, that is too much of a difference, even CPU time it drops a bit for a 10000 times bigger input. I believe it its faster but not this much. How about moving this one to a pull request so that we can check the code together? |
Constructor of std::string does not allow any moving. Instead, it always copies all data.
Except if pointer std::string is not used. However, that is used minorly in project.
This leads to too many unnecessary copying around data, which can be size of block (64mb).
Proposal, use custom class that will not be copying data, but moving it. Also, it will control number of owners and gets destructed when owners<=0
Other way is to use std::shared_ptrstd::string
Solving this will do some improvement to performance
The text was updated successfully, but these errors were encountered: