refactor(benchmark): make Benchmark::sync fallible#1414
Open
dcvz wants to merge 3 commits into
Open
Conversation
dcvz
force-pushed
the
refactor/fallible-benchmark-sync
branch
from
July 9, 2026 18:46
3883282 to
dca752a
Compare
nathanielsimard
left a comment
Member
There was a problem hiding this comment.
That's a good improvement. Is there a way to use the ServerError struct ins
| let error_sink = stream.errors.clone(); | ||
|
|
||
| Box::pin(async move { | ||
| MetalStreamBackend::wait_event_sync(fence)?; |
Member
There was a problem hiding this comment.
If wait_event_sync fails, the recorded faults stay in the sink and poison a later unrelated call. The drain should happen regardless of the wait's outcome.
| // profile instead of leaking into the next call on the stream. | ||
| let errors = self.flush_errors(stream_id); | ||
| if !errors.is_empty() { | ||
| return Err(ProfileError::Unknown { |
Member
There was a problem hiding this comment.
errors is a Vec<ServerError>, and ProfileError::Server(#[from] Box<ServerError>) exists at base.rs:71 for exactly this. It should be ProfileError::Server(Box::new(ServerError::ServerUnhealthy { errors, backtrace })). The pre-existing flush_errors at :160 does the same stringify, so both could be fixed together.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On asynchronous backends, kernel launches are fire-and-forget: compilation/validation errors and GPU faults often only become observable at synchronization. Since
sync()returned(), an implementor's only option was.unwrap(). That means a single benchmark whose kernel legitimately can't run on the current device (e.g. requesting 40 KiB of shared memory against Apple's 32 KiB limit) aborts the entire benchmark binary instead of failing that one bench. In practice this made full cubek benchmark sweeps impossible to complete on macOS.syncnow returnsResult<(), String>, propagated throughprofile_fullandrun(). Tworun()changes close holes the signature alone wouldn't fix:profile()overrides bypass the trait'ssync), a fault from the final samples surfaced at the next benchmark's leading sync and failed the wrong one.The first commit fixes Metal fault recording during sync/profiling (faults recorded by completion handlers during the fence wait were dropped or misattributed). Standalone fixes, but without them the trait's guarantee wouldn't hold on Metal.
Migration is one line per impl:
block_on(client.sync()).unwrap() → block_on(client.sync()).map_err(|e| format!("{e}")). The getting-started examples are updated.