Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auxflash: make startup a lot faster. #1959

Merged
merged 1 commit into from
Dec 26, 2024
Merged

Conversation

cbiffle
Copy link
Collaborator

@cbiffle cbiffle commented Dec 17, 2024

The auxflash server was computing a SHA3 of every potentially occupied slot in the QSPI flash, only to compare it to the stored SHA3 and then compare it to the expected SHA3 and then throw it away. This has been causing Sidecar startup to be linear in the number of valid images that have ever been flashed to auxflash, up to 16.

This change rearranges the logic, at least for startup. For each chunk, we now see if it even claims to have the right SHA. Only then do we compute the actual SHA to validate. This reduces an 11.6s delay observed on one Sidecar to just over 1s, and knocks 6s off the boot (something else is still delaying for 5s).

I haven't changed the behavior of the externally exposed read_slot_checksum operation, because it has no documentation and I can't figure out what it's used for, so I'm not sure I would get the semantics right or know how to test it.

Copy link
Contributor

@jgallagher jgallagher left a comment

Choose a reason for hiding this comment

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

LGTM 👍

continue;
};

if chck == actual {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if there are already ringbuf logs in this task, but - should we log if this condition is false? It seems like that would be very surprising.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure that it's that surprising; a difference between actual and claimed checksum could occur if a write is aborted partway through, for example.

Copy link
Contributor

@Aaron-Hartwig Aaron-Hartwig left a comment

Choose a reason for hiding this comment

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

Thanks for this improvement, Cliff!

The auxflash server was computing a SHA3 of every potentially occupied
slot in the QSPI flash, only to compare it to _the stored SHA3_ and then
compare it to _the expected SHA3_ and then throw it away. This has been
causing Sidecar startup to be linear in the number of valid images that
have ever been flashed to auxflash, up to 16.

This change rearranges the logic, at least for startup. For each chunk,
we now see if it even claims to have the right SHA. Only then do we
compute the actual SHA to validate. This reduces an 11.6s delay observed
on one Sidecar to just over 1s, and knocks 6s off the boot (something
else is still delaying for 5s).

I haven't changed the behavior of the externally exposed
`read_slot_checksum` operation, because it has no documentation and I
can't figure out what it's used for, so I'm not sure I would get the
semantics right or know how to test it.

Fixes #1955.
@cbiffle cbiffle force-pushed the cbiffle/auxflash-perf-fix branch from c8f545e to 06501cf Compare December 26, 2024 04:31
@cbiffle cbiffle enabled auto-merge (rebase) December 26, 2024 04:32
@cbiffle cbiffle merged commit 50eb989 into master Dec 26, 2024
116 of 125 checks passed
@cbiffle cbiffle deleted the cbiffle/auxflash-perf-fix branch December 26, 2024 04:38
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.

3 participants