Skip to content

Conversation

@jmpesp
Copy link
Contributor

@jmpesp jmpesp commented Dec 18, 2025

The 3/4 local storage PR added the ability to allocate local storage during sled reservation. This works but computing the entire set of all possible allocations is expensive. This PR wraps the logic into an Iterator, and yields all valid allocations one at a time.

The 3/4 local storage PR added the ability to allocate local storage
during sled reservation. This works but computing the entire set of all
possible allocations is expensive. This PR wraps the logic into an
Iterator, and yields all valid allocations one at a time.
Comment on lines 500 to 506

while let Some(possible_allocation) = self.queue.pop() {
let PossibleAllocations {
allocations,
candidates_left,
request_index,
} = possible_allocation;
Copy link
Member

Choose a reason for hiding this comment

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

feel free to ignore me but, this could also now be

Suggested change
while let Some(possible_allocation) = self.queue.pop() {
let PossibleAllocations {
allocations,
candidates_left,
request_index,
} = possible_allocation;
loop {
let PossibleAllocations {
allocations,
candidates_left,
request_index,
} = self.queue.pop()?;

which...is a different way of saying the same thing that is probably neither worse nor better in any kind of way

Comment on lines 298 to 308
#[derive(Clone, Debug)]
struct PossibleAllocationsForRequest<'a> {
request: &'a LocalStorageDisk,
candidate_datasets: HashSet<CandidateDataset>,
}

struct PossibleAllocations {
allocations: Vec<LocalStorageAllocation>,
candidates_left: HashSet<CandidateDataset>,
request_index: usize,
}
Copy link
Member

Choose a reason for hiding this comment

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

it might be nice for these to have some commentary explaining what the difference between them is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In edc0b56 I added comments and changed the types to distinguish between an incomplete list of allocations, and a completed one. I think this makes more sense to read, let me know what you think

Comment on lines 335 to 336
allocations_to_perform: Vec<PossibleAllocationsForRequest<'a>>,
queue: BinaryHeap<PossibleAllocations>,
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice if there was some commentary explaining what these fields mean...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also edc0b56

//
// Start from no allocations made yet, a list of allocations to perform
// (stored in `requests`), and all of the available zpools on the sled.
// Use a BinaryHeap to get a sorted list.
Copy link
Member

Choose a reason for hiding this comment

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

maybe worth saying "sorted by the number of possible allocations", since otherwise, you have to go and track down the Ord impl to figure that out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this line in edc0b56, I think it reads better.

sled_target: SledUuid,
zpools_for_sled: NonEmpty<ZpoolGetForSledReservationResult>,
local_storage_disks: &'a [LocalStorageDisk],
) -> Result<Self, ()> {
Copy link
Member

Choose a reason for hiding this comment

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

take it or leave it: this maybe could just be an Option? It's not an error, it's just...there are no valid allocations here`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely that makes sense, done in edc0b56

@jmpesp jmpesp merged commit cfc976d into oxidecomputer:main Dec 19, 2025
16 checks passed
@jmpesp jmpesp deleted the speed_up_slowed_down_sled_reservation branch December 19, 2025 13:42
@AlejandroME AlejandroME added the local storage relating to the local storage feature label Dec 19, 2025
@AlejandroME AlejandroME added this to the 18 milestone Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

local storage relating to the local storage feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants