#187 Smallobject benchmark in qtcreator,ubuntu,notebook

v1.0_(example)
closed-duplicate
None
8
2013-06-18
2012-12-21
vaneyli
No

output shows :
the speed of the smallobject is much slower than the default, also the boost!!! why? please help me:)

I've downloaded. the newest code .

//part of output

Allocator Benchmark Tests with 2 bytes big objects

new = global new/delete sizeof(A) = 2
SmallObj = Loki::SmallObject sizeof(B) = 8
ValueObj = Loki::SmallValueObject sizeof(C) = 2
boost = boost::object_pool sizeof(D) = 2
allocator= std::allocator sizeof(A) = 2
malloc = std::malloc/free sizeof(A) = 2

1000000 times 'delete new T'
new : seconds: 40 relative time: 100% speed-up factor: 1
SmallObj : seconds: 280 relative time: 700% speed-up factor: 0.14
ValueObj : seconds: 270 relative time: 675% speed-up factor: 0.15
boost : seconds: 50 relative time: 125% speed-up factor: 0.8
allocator: seconds: 60 relative time: 150% speed-up factor: 0.67
malloc : seconds: 40 relative time: 100% speed-up factor: 1

N=3 : 1000000 times 'delete[] new T[N]'
new : seconds: 50 relative time: 100% speed-up factor: 1
SmallObj : seconds: 320 relative time: 640% speed-up factor: 0.16
ValueObj : seconds: 320 relative time: 640% speed-up factor: 0.16
boost : seconds: 50 relative time: 100% speed-up factor: 1
allocator: seconds: 60 relative time: 120% speed-up factor: 0.83
malloc : seconds: 40 relative time: 80% speed-up factor: 1.25

i=0...1000000 : 1. 'arr[i] = new T' 2. 'delete arr[i]'
1. new : seconds: 40 relative time: 100% speed-up factor: 1
2. new : seconds: 30 relative time: 100% speed-up factor: 1

1. SmallObj : seconds: 220 relative time: 550% speed-up factor: 0.18
2. SmallObj : seconds: 200 relative time: 667% speed-up factor: 0.15

1. ValueObj : seconds: 220 relative time: 550% speed-up factor: 0.18
2. ValueObj : seconds: 180 relative time: 600% speed-up factor: 0.17

1. boost : seconds: 30 relative time: 75% speed-up factor: 1.33
2. boost : boost::object_pool is not tested because it's too slow

1. allocator: seconds: 40 relative time: 100% speed-up factor: 1
2. allocator: seconds: 20 relative time: 67% speed-up factor: 1.5

1. malloc : seconds: 20 relative time: 50% speed-up factor: 2
2. malloc : seconds: 20 relative time: 67% speed-up factor: 1.5

Discussion

  • vaneyli

    vaneyli - 2012-12-29

    *Loki:
    Version 0.1.7
    January 2009
    *ubuntu c++ complier:
    g++ 4.4.5

    *other:
    I'v found that the sgl stl v3.3 has adopted the same skill as the smallobject in the loki.
    But the stl in the c++ complier just use the default alloc.

    answer:
    the present malloc or operator new has been optimized . ????

    help me:)

     
  • vaneyli

    vaneyli - 2012-12-29
    • priority: 5 --> 8
     
  • Richard Sposato

    Richard Sposato - 2013-06-18

    Hi vaneyli,

    Runtime performance is a known problem with Loki. (You can find multiple old bug reports on this topic.) Because of how the small object allocator is implemented, it will not be easy to improve speed.

    Loki's small object allocator maintains vectors of containers of memory chunks. Although the very low-level code in the Chunk class is well-optimized for O(1) performance (constant runtime performance), the small object allocator searches through the container when it has to deallocate a piece of memory, it searches through the containers. That search can take O(n) (linear runtime performance) per call to deallocate in a worst-case scenario. That's why its overall runtime performance is so slow.

    I once made a version of Loki where the containers stored all the memory Chunks in sorted order so that deallocations would be quicker. However, the overhead of maintaining the sorted order made the overall performance worse.

    The take-away message is that although Loki's allocator provides very good performance in terms of memory efficiency, it does not provide good performance in terms of time. It's a tradeoff.

    Sincerely,

    Rich

     
  • Richard Sposato

    Richard Sposato - 2013-06-18
    • status: open --> closed-duplicate
    • assigned_to: Richard Sposato
    • Group: --> v1.0_(example)
     

Log in to post a comment.