Skip to content

Conversation

@writegsqword
Copy link
Contributor

@writegsqword writegsqword commented Nov 22, 2025

In the previous line the comment says this:
"We only do this for sizes larger than 1024 bytes. In other words we can live with some wasted space in zones that manage chunks smaller than ZONE_1024"

I believe the intent here is as follows:

  1. For chunks larger than 1024, check if too much space is wasted. If the wasted space is "not acceptable", this zone is not available for serving this particular allocation.
  2. For chunks smaller or equal to 1024, if the zone is also less than less than or equal to 1024(and obviously, fits the allocation), then use that zone.

However, the code does this in effect:

  1. For chunks larger than 1024, check if too much space is wasted. If the wasted space is "not acceptable", this zone is not available for serving this particular allocation(as intended).
  2. For chunks smaller or equal to 1024, the zone is ALWAYS VALID(if it has empty slots of course).

This causes a huge amount of wasted space when only a large zone is available for allocation, and small allocation requests are served.

@struct
Copy link
Owner

struct commented Dec 14, 2025

Apologies for the delay on responding to this issue. It's a good catch, and I think its a valid bug when called from the slow path in find_suitable_zone(). Luckily the hot path in find_suitable_zone() that utilizes the lookup table will hopefully have already found an exact match, regardless the slow case is bound to happen and waste memory. Thanks.

@struct struct merged commit b6a0e2e into struct:master Dec 14, 2025
3 of 10 checks passed
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