Skip to content
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

Cache the block which most recently successfully allocated something #1284

Conversation

AnyOldName3
Copy link
Contributor

Otherwise, once the most recently allocated block was full, all allocations would need to scan the whole collection of blocks to find free space, which could take a while if lots of blocks had already been allocated but contained free space due to things being freed.

For the app I've tried this with, without this PR, loading a large scene takes 1:08 and reloading it takes 19:58, but with this PR, initial loading takes 1:04 (so about the same) and reloading it takes only 0:54, just 4.5% as long as without. I'm going to run some of the allocation benchmarks from the vsgExamples AllocatorRefactor branch, and probably tweak them so they also measure how much slower or faster reusing blocks is as it's possible I've ended up making something worse.

Otherwise, once the most recently allocated block was full, all allocations would need to scan the whole collection of blocks to find free space, which could take a while if lots of blocks had already been allocated but contained free space due to things being freed.
@robertosfield
Copy link
Collaborator

ooo that's a big improvement. I think this change might need some refinement, but broadly it looks a sensible direction to follow. Once I've wrapped up my present dev work I'll have do a proper review.

@AnyOldName3
Copy link
Contributor Author

Generally, I'd be in favour of using an off-the-shelf allocator instead of a custom one so we could be relatively sure there weren't any undiscovered pathological cases that people would run into, but I did a review of what's available, and the ones that natively supported something like the VSG affinity system (which they mostly referred to as multiple heaps) either were tied to a specific platform or didn't support allocating and freeing from one heap on different threads. Mimalloc has microsoft/mimalloc#925 where one of the maintainers states that they eventually intend to make it possible, so the situation may improve, but we're stuck with something custom in the short term.

@AnyOldName3
Copy link
Contributor Author

I've altered the vsggroups example so it can detect the problems without this PR and show the benefit when this MR is added. That's available as vsg-dev/vsgExamples#318.

Here are some raw terminal logs from some testing:

Original

C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12 --std
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.07351
traversal time : 3.11266
destruction time : 1.35566
total time : 5.54184

Nodes constructed per second : 2.08377e+07
Nodes visited per second     : 7.18666e+07
Nodes destructed per second : 1.65009e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.11
destruction time : 1.34158
total time : 5.53464

Nodes constructed per second : 2.01529e+07
Nodes visited per second     : 7.25564e+07
Nodes destructed per second : 1.66741e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.05256
traversal time : 3.09339
destruction time : 1.35555
total time : 5.50149

Nodes constructed per second : 2.12527e+07
Nodes visited per second     : 7.23143e+07
Nodes destructed per second : 1.65023e+07
average construction time : 1.07869
average traversal time : 3.09637
average destruction time : 1.35093
average total time : 5.52599

Average Nodes constructed per second : 2.07378e+07
Average Nodes visited per second     : 7.22446e+07
Average Nodes destructed per second : 1.65587e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12 --std
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.04927
traversal time : 3.06028
destruction time : 1.3318
total time : 5.44136

Nodes constructed per second : 2.13192e+07
Nodes visited per second     : 7.30966e+07
Nodes destructed per second : 1.67965e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.08185
destruction time : 1.33953
total time : 5.50509

Nodes constructed per second : 2.06772e+07
Nodes visited per second     : 7.25414e+07
Nodes destructed per second : 1.66996e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.06069
traversal time : 3.11048
destruction time : 1.3558
total time : 5.52696

Nodes constructed per second : 2.10898e+07
Nodes visited per second     : 7.1917e+07
Nodes destructed per second : 1.64992e+07
average construction time : 1.06394
average traversal time : 3.08482
average destruction time : 1.34238
average total time : 5.49114

Average Nodes constructed per second : 2.10253e+07
Average Nodes visited per second     : 7.25151e+07
Average Nodes destructed per second : 1.66642e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12 --std
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.0181
traversal time : 3.08197
destruction time : 1.32948
total time : 5.42955

Nodes constructed per second : 2.1972e+07
Nodes visited per second     : 7.25821e+07
Nodes destructed per second : 1.68259e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.08271
destruction time : 1.3332
total time : 5.50733

Nodes constructed per second : 2.06608e+07
Nodes visited per second     : 7.23601e+07
Nodes destructed per second : 1.67789e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.09647
traversal time : 3.09637
destruction time : 1.34625
total time : 5.5391

Nodes constructed per second : 2.04014e+07
Nodes visited per second     : 7.22446e+07
Nodes destructed per second : 1.66162e+07
average construction time : 1.06576
average traversal time : 3.08993
average destruction time : 1.33631
average total time : 5.49199

Average Nodes constructed per second : 2.09894e+07
Average Nodes visited per second     : 7.23953e+07
Average Nodes destructed per second : 1.67399e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.898412
traversal time : 0.963689
destruction time : 1.04278
total time : 2.90488

Nodes constructed per second : 2.48991e+07
Nodes visited per second     : 2.32125e+08
Nodes destructed per second : 2.14519e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 78.0274
destruction time : 1.05247
total time : 80.0821

Nodes constructed per second : 286689
Nodes visited per second     : 2.23205e+08
Nodes destructed per second : 2.12544e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 99.4148
traversal time : 1.01104
destruction time : 1.05234
total time : 101.478

Nodes constructed per second : 225013
Nodes visited per second     : 2.21253e+08
Nodes destructed per second : 2.1257e+07
average construction time : 59.4469
average traversal time : 0.992311
average destruction time : 1.0492
average total time : 61.4884

Average Nodes constructed per second : 376296
Average Nodes visited per second     : 2.2543e+08
Average Nodes destructed per second : 2.13207e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.898926
traversal time : 0.97702
destruction time : 1.08914
total time : 2.96509

Nodes constructed per second : 2.48848e+07
Nodes visited per second     : 2.28958e+08
Nodes destructed per second : 2.05388e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 78.0546
destruction time : 1.0901
total time : 80.2102

Nodes constructed per second : 286589
Nodes visited per second     : 2.09948e+08
Nodes destructed per second : 2.05208e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 98.3369
traversal time : 1.04353
destruction time : 1.08198
total time : 100.462

Nodes constructed per second : 227479
Nodes visited per second     : 2.14365e+08
Nodes destructed per second : 2.06747e+07
average construction time : 59.0968
average traversal time : 1.02868
average destruction time : 1.08707
average total time : 61.2126

Average Nodes constructed per second : 378525
Average Nodes visited per second     : 2.1746e+08
Average Nodes destructed per second : 2.05778e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.896486
traversal time : 0.968111
destruction time : 1.04935
total time : 2.91395

Nodes constructed per second : 2.49526e+07
Nodes visited per second     : 2.31065e+08
Nodes destructed per second : 2.13176e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 75.2052
traversal time : 1.05599
destruction time : 1.06265
total time : 77.3239

Nodes constructed per second : 297448
Nodes visited per second     : 2.11836e+08
Nodes destructed per second : 2.10508e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 100.427
traversal time : 1.00235
destruction time : 1.06432
total time : 102.493

Nodes constructed per second : 222746
Nodes visited per second     : 2.23172e+08
Nodes destructed per second : 2.10178e+07
average construction time : 58.8428
average traversal time : 1.00882
average destruction time : 1.05877
average total time : 60.9103

Average Nodes constructed per second : 380159
Average Nodes visited per second     : 2.21741e+08
Average Nodes destructed per second : 2.11279e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]>

With this PR

C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12 --std
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.1584
traversal time : 3.05361
destruction time : 1.35606
total time : 5.56807

Nodes constructed per second : 1.93108e+07
Nodes visited per second     : 7.32563e+07
Nodes destructed per second : 1.6496e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.11001
destruction time : 1.36336
total time : 5.52443

Nodes constructed per second : 2.01526e+07
Nodes visited per second     : 7.33177e+07
Nodes destructed per second : 1.64077e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.04384
traversal time : 3.05945
destruction time : 1.35318
total time : 5.45648

Nodes constructed per second : 2.14301e+07
Nodes visited per second     : 7.31164e+07
Nodes destructed per second : 1.65311e+07
average construction time : 1.10408
average traversal time : 3.05471
average destruction time : 1.35754
average total time : 5.51633

Average Nodes constructed per second : 2.02608e+07
Average Nodes visited per second     : 7.323e+07
Average Nodes destructed per second : 1.64781e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12 --std
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.04064
traversal time : 3.01122
destruction time : 1.34543
total time : 5.39729

Nodes constructed per second : 2.1496e+07
Nodes visited per second     : 7.42876e+07
Nodes destructed per second : 1.66263e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.01964
destruction time : 1.36452
total time : 5.38044

Nodes constructed per second : 2.19388e+07
Nodes visited per second     : 7.46577e+07
Nodes destructed per second : 1.63938e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.07288
traversal time : 2.99439
destruction time : 1.38134
total time : 5.44861

Nodes constructed per second : 2.08502e+07
Nodes visited per second     : 7.4705e+07
Nodes destructed per second : 1.61941e+07
average construction time : 1.04439
average traversal time : 3.00063
average destruction time : 1.36376
average total time : 5.40878

Average Nodes constructed per second : 2.14189e+07
Average Nodes visited per second     : 7.45496e+07
Average Nodes destructed per second : 1.64029e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12 --std
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.998677
traversal time : 2.99658
destruction time : 1.33579
total time : 5.33105

Nodes constructed per second : 2.23992e+07
Nodes visited per second     : 7.46504e+07
Nodes destructed per second : 1.67464e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.07938
traversal time : 2.98664
destruction time : 1.34218
total time : 5.4082

Nodes constructed per second : 2.07246e+07
Nodes visited per second     : 7.48989e+07
Nodes destructed per second : 1.66666e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 1.07517
traversal time : 2.99022
destruction time : 1.35446
total time : 5.41985

Nodes constructed per second : 2.08056e+07
Nodes visited per second     : 7.48093e+07
Nodes destructed per second : 1.65156e+07
average construction time : 1.05108
average traversal time : 2.99115
average destruction time : 1.34414
average total time : 5.38637

Average Nodes constructed per second : 2.12826e+07
Average Nodes visited per second     : 7.4786e+07
Average Nodes destructed per second : 1.66423e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.901902
traversal time : 0.870848
destruction time : 1.06786
total time : 2.84061

Nodes constructed per second : 2.48027e+07
Nodes visited per second     : 2.56872e+08
Nodes destructed per second : 2.09481e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.724492
destruction time : 1.08054
total time : 2.76403

Nodes constructed per second : 3.08763e+07
Nodes visited per second     : 2.3326e+08
Nodes destructed per second : 2.07022e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.736282
traversal time : 0.891482
destruction time : 1.0673
total time : 2.69506

Nodes constructed per second : 3.03819e+07
Nodes visited per second     : 2.50926e+08
Nodes destructed per second : 2.09591e+07
average construction time : 0.787559
average traversal time : 0.907109
average destruction time : 1.0719
average total time : 2.76657

Average Nodes constructed per second : 2.84038e+07
Average Nodes visited per second     : 2.46603e+08
Average Nodes destructed per second : 2.08691e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.889964
traversal time : 0.908313
destruction time : 1.07795
total time : 2.87623

Nodes constructed per second : 2.51354e+07
Nodes visited per second     : 2.46277e+08
Nodes destructed per second : 2.0752e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.726003
destruction time : 1.0793
total time : 2.73387

Nodes constructed per second : 3.0812e+07
Nodes visited per second     : 2.40906e+08
Nodes destructed per second : 2.0726e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.739652
traversal time : 0.894422
destruction time : 1.08063
total time : 2.71471

Nodes constructed per second : 3.02434e+07
Nodes visited per second     : 2.50101e+08
Nodes destructed per second : 2.07005e+07
average construction time : 0.785206
average traversal time : 0.910433
average destruction time : 1.0793
average total time : 2.77494

Average Nodes constructed per second : 2.84888e+07
Average Nodes visited per second     : 2.45703e+08
Average Nodes destructed per second : 2.07261e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]> .\vsggroups.exe -l 12
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.912901
traversal time : 0.926556
destruction time : 1.07393
total time : 2.91339

Nodes constructed per second : 2.45039e+07
Nodes visited per second     : 2.41428e+08
Nodes destructed per second : 2.08296e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.727943
traversal time : 0.9381
destruction time : 1.06853
total time : 2.73457

Nodes constructed per second : 3.07299e+07
Nodes visited per second     : 2.38457e+08
Nodes destructed per second : 2.0935e+07
using VsgVisitor
type : vsg::Group
numNodes : 22369621
numBytes : 850045584
average node size : 38
numNodesVisited : 223696210
construction time : 0.740066
traversal time : 0.873696
destruction time : 1.06987
total time : 2.68363

Nodes constructed per second : 3.02265e+07
Nodes visited per second     : 2.56034e+08
Nodes destructed per second : 2.09088e+07
average construction time : 0.793636
average traversal time : 0.912784
average destruction time : 1.07078
average total time : 2.7772

Average Nodes constructed per second : 2.81862e+07
Average Nodes visited per second     : 2.4507e+08
Average Nodes destructed per second : 2.0891e+07
C:\Dev\VulkanSceneGraph\vsgExamples\build\bin\Release [master ≡ +1 ~1 -0 !]>

I'll collate the data to make it nicer to read...

@AnyOldName3
Copy link
Contributor Author

The data from another set of runs (as the first were missing some lines due to Windows 10 still shipping PowerShell with PSReadLine 2.0 installed, which has a bug that was fixed in 2018 that makes some lines disappear from the scrollback buffer with some terminals), but formatted as a table so it's vaguely readable:

Original

Allocator Pass Construction time Traversal time Destruction time Total time Construction rate Traversal rate Destruction rate
std 0 1.02466 3.0281 1.30101 5.35376 2.18E+07 7.39E+07 1.72E+07
std 1 1.02495 3.06137 1.35196 5.43827 2.18E+07 7.31E+07 1.65E+07
std 2 1.01582 3.05855 1.31805 5.39242 2.20E+07 7.31E+07 1.70E+07
std Average 1.02181 3.04934 1.32367 5.39482 2.19E+07 7.34E+07 1.69E+07
std 0 1.00797 3.02305 1.27342 5.30444 2.22E+07 7.40E+07 1.76E+07
std 1 1.08211 3.10958 1.34273 5.53441 2.07E+07 7.19E+07 1.67E+07
std 2 1.027 3.10732 1.29293 5.42725 2.18E+07 7.20E+07 1.73E+07
std Average 1.03902 3.07998 1.30303 5.42203 2.15E+07 7.26E+07 1.72E+07
std 0 1.00203 3.10911 1.32102 5.43215 2.23E+07 7.19E+07 1.69E+07
std 1 1.04492 3.01074 1.29855 5.35421 2.14E+07 7.43E+07 1.72E+07
std 2 1.04625 3.05348 1.35697 5.4567 2.14E+07 7.33E+07 1.65E+07
std Average 1.03107 3.05777 1.32551 5.41435 2.17E+07 7.32E+07 1.69E+07
intrusive 0 0.959542 0.983801 1.04838 2.99173 2.33E+07 2.27E+08 2.13E+07
intrusive 1 76.78 1.03939 1.05049 78.8699 291347 2.15E+08 2.13E+07
intrusive 2 102.748 0.996635 1.0704 104.815 217714 2.24E+08 2.09E+07
intrusive Average 60.1625 1.00661 1.05643 62.2255 371820 2.22E+08 2.12E+07
intrusive 0 0.932389 0.97655 1.03791 2.94685 2.40E+07 2.29E+08 2.16E+07
intrusive 1 75.3725 1.0134 1.04399 77.4298 296788 2.21E+08 2.14E+07
intrusive 2 97.1932 1.00882 1.04227 99.2442 230156 2.22E+08 2.15E+07
intrusive Average 57.8327 0.999589 1.04139 59.8736 386799 2.24E+08 2.15E+07
intrusive 0 0.932609 0.990708 1.0673 2.99061 2.40E+07 2.26E+08 2.10E+07
intrusive 1 79.665 1.03739 1.06861 81.771 280796 2.16E+08 2.09E+07
intrusive 2 98.5477 0.97443 1.06761 100.59 226993 2.30E+08 2.10E+07
intrusive Average 59.7151 1.00084 1.06784 61.7838 374606 2.24E+08 2.09E+07
std Average 0 1.011553333 3.05342 1.298483333 5.36345 22116133.33 73273033.33 17231433.33
Average 12 1.040175 3.06684 1.326865 5.4338767 21514816.67 72949250 16865133.33
intrusive Average 0 0.941513333 0.983686333 1.051196667 2.9763967 23763533.33 227414000 21282933.33
Average 12 88.3844 1.0116775 1.057228333 90.453317 257299 221225000 21161466.67

New

Allocator Pass Construction time Traversal time Destruction time Total time Construction rate Traversal rate Destruction rate
std 0 0.988737 2.97296 1.28652 5.24821 2.26E+07 7.52E+07 1.74E+07
std 1 1.05222 2.93875 1.29863 5.28959 2.13E+07 7.61E+07 1.72E+07
std 2 1.0644 2.97248 1.2872 5.32409 2.10E+07 7.53E+07 1.74E+07
std Average 1.03512 2.9614 1.29078 5.28729 2.16E+07 7.55E+07 1.73E+07
std 0 1.03657 2.95491 1.28253 5.27401 2.16E+07 7.57E+07 1.74E+07
std 1 1.06806 2.95792 1.28121 5.30719 2.09E+07 7.56E+07 1.75E+07
std 2 1.03851 3.00261 1.34675 5.38787 2.15E+07 7.45E+07 1.66E+07
std Average 1.04772 2.97181 1.3035 5.32303 2.14E+07 7.53E+07 1.72E+07
std 0 1.03263 2.97959 1.32292 5.33515 2.17E+07 7.51E+07 1.69E+07
std 1 1.01171 2.94223 1.29528 5.24921 2.21E+07 7.60E+07 1.73E+07
std 2 1.01288 2.97323 1.30579 5.2919 2.21E+07 7.52E+07 1.71E+07
std Average 1.01907 2.96501 1.308 5.29208 2.20E+07 7.54E+07 1.71E+07
intrusive 0 0.918469 0.947844 1.09361 2.95993 2.44E+07 2.36E+08 2.05E+07
intrusive 1 0.729437 0.946425 1.08236 2.75822 3.07E+07 2.36E+08 2.07E+07
intrusive 2 0.74219 0.907451 1.0768 2.72644 3.01E+07 2.47E+08 2.08E+07
intrusive Average 0.796698 0.933907 1.08426 2.81486 2.81E+07 2.40E+08 2.06E+07
intrusive 0 0.928767 0.937689 1.05957 2.92602 2.41E+07 2.39E+08 2.11E+07
intrusive 1 0.720648 0.979823 1.08049 2.78096 3.10E+07 2.28E+08 2.07E+07
intrusive 2 0.735943 0.924255 1.06408 2.72428 3.04E+07 2.42E+08 2.10E+07
intrusive Average 0.79512 0.947256 1.06805 2.81042 2.81E+07 2.36E+08 2.09E+07
intrusive 0 0.920807 0.931522 1.06723 2.91955 2.43E+07 2.40E+08 2.10E+07
intrusive 1 0.72225 0.965551 1.06364 2.75144 3.10E+07 2.32E+08 2.10E+07
intrusive 2 0.734446 0.912303 1.06888 2.71563 3.05E+07 2.45E+08 2.09E+07
intrusive Average 0.792501 0.936458 1.06658 2.79554 2.82E+07 2.39E+08 2.10E+07
std Average 0 1.019312333 2.969153333 1.297323333 5.28579 21955833.33 75341100 17246200
Average 12 1.041296667 2.964536667 1.302476667 5.3083083 21492633.33 75461416.67 17179183.33
intrusive Average 0 0.922681 0.939018333 1.07347 2.9351667 24244700 238235666.7 20842433.33
Average 12 0.730819 0.939301333 1.072708333 2.7428283 30612283.33 238346333.3 20854450

In light of this, I can say that:

  • Reuse of blocks has changed from ludicrously slow to being faster than using fresh blocks.
  • There's a possibility that it's slightly improved traversal times when blocks are reused, but it's not a significant enough effect to be conclusive.
  • It doesn't look like anything was made worse.

The OS doing secret stuff under the hood should have been prevented by running the std allocator test first as that should have meant there was enough memory that wasn't being used for disk cache or anything else that might need paging out.

@robertosfield
Copy link
Collaborator

Wow, that's a huge demonstration of the multi create/destroy performance bug. Kudos.

I'm aiming to wrap up the PolytopeIntersector work today and then can do full review/test.

@robertosfield robertosfield merged commit b034a0c into vsg-dev:master Oct 2, 2024
8 checks passed
@robertosfield
Copy link
Collaborator

I have done a code review and the change as is looks perfectly safe and straight forward so I've gone ahead and merged it. I'm surprised I missed this small optimization of the allocation fallback code as it seems so obvious now, but hey gotta love open source and many eye balls, even one extra pair can make a difference :-)

I'll have a longer think about whether there is a further refinement we can make, but even I come up with something it'll not make a massive further improvement like this fix did as the main bottleneck has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants