Skip to content

Perf improvements 3 26#237

Merged
struct merged 2 commits intomasterfrom
perf_improvements_3_26
Mar 15, 2026
Merged

Perf improvements 3 26#237
struct merged 2 commits intomasterfrom
perf_improvements_3_26

Conversation

@struct
Copy link
Owner

@struct struct commented Mar 15, 2026

Numerous performance improvements and long overdue bug fixes

@struct struct merged commit 6599811 into master Mar 15, 2026
19 checks passed
zone_lookup_table_t zone_lookup_table[(SMALL_SIZE_MAX >> 4) + 4];
/* For chunk sizes >= 1024 our bitmap size is smaller
* than a page. This optimization preallocates pages to
* than a page. This optimization preallocates pages tog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tog?

Comment on lines +1077 to +1080
/* Pre-lock hot path: scan the thread-local zone cache using only
* thread-local data (chunk_size comparison and pointer read). No
* zone struct fields are dereferenced here. Validation happens
* under the lock via is_zone_usable(). */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to document what is scanned for I think.


if(_root->big_zone_used == NULL) {
LOG_AND_ABORT("There are no big zones allocated");
UNLOCK_BIG_ZONE_USED();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a functional change to me, instead of simply an optimization, isn't it?

Comment on lines +2162 to +2163
#if DEBUG || FUZZ_MODE
_verify_zone(&_root->zones[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, isn't this a security property?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is only called from the destructor which verifies heap consistency when the program exits. Useful for debugging but not release.

return OK;
}
#endif
int main(void) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be in an #else?

Comment on lines +364 to +365
## Build a performance-optimized library with the most expensive security
## features disabled. Intended for benchmarking and performance measurement.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sounds like cheating to me :P

* If `SANITIZE_CHUNKS` is set all user chunks are cleared when passed to `iso_free` with the constant `0xde`.
* When freeing a chunk the canary in adjacent chunks above/below are verified.
* Some important zone metadata pointers are masked in-between `iso_alloc` and `iso_free` operations.
* When `MASK_PTRS` is enabled (default) the `user_pages_start` and `bitmap_start` pointers stored in zone metadata are XOR'd with a per-zone random secret between alloc and free operations, making them useless to an attacker who reads or corrupts zone metadata.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to explicit where the "per-zone random secret" is stored.

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