From d5b773b2bc5b1ed5b7a4be09e910d44fddeebed6 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 3 Nov 2018 04:40:13 -0400 Subject: [PATCH] clarify documentation about the 0 byte size class --- README.md | 11 +++++++---- calculate_waste.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dfa35bc..e969855 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,8 @@ was a bit less important and if a core goal was finding latent bugs. with a strong keyed hash due to performance limitations) * Possible slab locations are skipped and remain memory protected, leaving slab size class regions interspersed with guard pages -* Zero size allocations are memory protected +* Zero size allocations are a dedicated size class with the entire region + remaining non-readable and non-writable * Protected allocator state (including all metadata) * Address space for state is entirely reserved during initialization and never reused for allocations or anything else @@ -277,8 +278,10 @@ overhead and can easily dwarf the cost of an efficient CSPRNG. # Size classes -The zero byte size class is a special case of the smallest regular size class. It's allocated in a -separate region with the memory left non-readable and non-writable. +The zero byte size class is a special case of the smallest regular size class. +It's allocated in a dedicated region like other size classes but with the slabs +never being made readable and writable so the only memory usage is for the slab +metadata. The slab slot count for each size class is not yet finely tuned beyond choosing values avoiding internal fragmentation for slabs (i.e. avoiding wasted space due to page size rounding). @@ -292,7 +295,7 @@ slabs containing them: | size class | worst case internal fragmentation | slab slots | slab size | worst case internal fragmentation for slabs | | - | - | - | - | - | -| 16 | 100% | 256 | 4096 | 0.0% | +| 16 | 93.75% | 256 | 4096 | 0.0% | | 32 | 46.875% | 128 | 4096 | 0.0% | | 48 | 31.25% | 85 | 4096 | 0.390625% | | 64 | 23.4375% | 64 | 4096 | 0.0% | diff --git a/calculate_waste.py b/calculate_waste.py index 173d148..552c5b1 100755 --- a/calculate_waste.py +++ b/calculate_waste.py @@ -24,7 +24,7 @@ size_class_slots = [ 6, 5, 4, 4 ] -fragmentation = [100] +fragmentation = [100 - 1 / 16 * 100] for i in range(len(size_classes) - 1): size_class = size_classes[i + 1]