zig/lib/std/heap
Ryan Liptak ec0f76c599 GeneralPurposeAllocator.searchBucket: check current bucket before searching the list
Follow up to #17383. This is a minor optimization that only matters when a small allocation is resized/free'd soon after it is allocated.

The only real difference I was able to observe with this was via a synthetic benchmark that allocates a full bucket and then frees all but one of the slots, over and over in a loop:

Debug build:

Benchmark 1 (9 runs): gpa-degen-master.exe
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           575ms ± 5.19ms     569ms …  583ms          0 ( 0%)        0%
  peak_rss           43.8MB ± 1.37KB    43.8MB … 43.8MB          1 (11%)        0%
Benchmark 2 (10 runs): gpa-degen-search-cur.exe
  measurement          mean ± σ            min … max           outliers         delta
  wall_time           532ms ± 5.55ms     520ms …  539ms          0 ( 0%)        -  7.5% ±  0.9%
  peak_rss           43.8MB ± 65.2KB    43.8MB … 44.0MB          1 (10%)          +  0.0% ±  0.1%

ReleaseFast build:

Benchmark 1 (129 runs): gpa-degen-master-release.exe
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          38.9ms ± 1.12ms    36.7ms … 42.4ms          8 ( 6%)        0%
  peak_rss           23.2MB ± 2.39KB    23.2MB … 23.2MB          0 ( 0%)        0%
Benchmark 2 (151 runs): gpa-degen-search-cur-release.exe
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          33.2ms ±  999us    31.9ms … 36.3ms         20 (13%)        - 14.7% ±  0.6%
  peak_rss           23.2MB ± 2.26KB    23.2MB … 23.2MB          0 ( 0%)          +  0.0% ±  0.0%
2023-10-04 02:55:54 -07:00
..
arena_allocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
general_purpose_allocator.zig GeneralPurposeAllocator.searchBucket: check current bucket before searching the list 2023-10-04 02:55:54 -07:00
log_to_writer_allocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
logging_allocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
memory_pool.zig std: enable FailingAllocator to fail on resize 2023-09-06 19:06:32 +03:00
PageAllocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
sbrk_allocator.zig std: add SbrkAllocator and use it for Plan 9 2023-08-02 17:39:52 -04:00
ThreadSafeAllocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
WasmAllocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
WasmPageAllocator.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00