mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
90709dfd21
Allocations required a sequential scan through the allocation list for both contexts and memory. This was very inefficient since for the most part individual memory allocations are seldom freed directly, rather they are freed when their context is freed. For both types of allocations track an index for the lowest free position. After an allocation of the free position, a sequential search will be required for the next allocation but this is still far better than doing a scan for every allocation. With a moderately-sized dataset (500 history entries in backup.info), there is a 237X performance improvement when combined with the f74e88bb refactor. Before: % cumulative self time seconds seconds name 65.11 331.37 331.37 memContextAlloc 16.19 413.78 82.40 memContextCurrent 14.74 488.81 75.03 memContextTop 2.65 502.29 13.48 memContextNewIndex 1.18 508.31 6.02 memFind After: % cumulative self time seconds seconds name 94.69 2.14 2.14 memFind Finding memory allocations in order to free or resize them is the next bottleneck, but this does not seem to be a major issue presently.