Skip to content

Reworked MemChunk to add a reserve method

ThosRTanner requested to merge ThosRTanner/pan:memchunk-tweaks into master

the first commit is reformatting with clang-format. I've also added the clang-format settings I've used (seeing as the formatting is fairly inconsistent in the project).

Changes to memchunk:

When looking at reasons why large groups took a long time to deal with, I discovered MemChunk::grow was called a lot for large groups. It allocates 16k chunks (apparently less memory allocation overhead) and will clearly waste some unless your object sizes are friendly. I think it might have been trying to make the data whole pages, but there's no way the alignment could be guaranteed. It also zeroises the allocated memory which is a bit pointless (assuming your constructors initialise everything they should, which was addressed in an earlier PR using cppcheck).

So instead I've made it allocate in chunks of 16k objects (which is arguably a bit excessive) and have also supplied a reserve method which will allow allocation of a precise number of objects, which is now used when reading in groups.

This has also simplified the destructor code slightly.

Merge request reports