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

Warn if a task takes a long time to poll #345

Merged
merged 14 commits into from
Jan 3, 2024

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Mar 24, 2023

This should help detect small freezes.

Before merging this PR, the freezes should actually be fixed, so as to not start printing warnings to the users.

@github-actions
Copy link

github-actions bot commented Mar 24, 2023

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
        +410 ┊ <smoldot_light_wasm::init::init::{{closure}}::FutureAdapter<F> as core::future::future::Future>::poll::h3d2cf17ee8b39776
        +192 ┊ data[0]
         +17 ┊ <&mut T as core::fmt::Display>::fmt::hb5c15821b68b5c77
          +5 ┊ elem[0]
        +709 ┊ Σ [4 Total Rows]

@tomaka
Copy link
Contributor Author

tomaka commented Mar 24, 2023

One freeze probably comes from here:

smoldot/lib/src/sync/all.rs

Lines 1172 to 1220 in b7bf5b9

warp_sync::ProcessOne::BuildRuntime(inner) => {
// TODO: errors not reported to upper layer
// TODO: make these parameters configurable
match inner.build(ExecHint::CompileAheadOfTime, false).0 {
warp_sync::WarpSync::InProgress(inner) => {
self.inner = AllSyncInner::GrandpaWarpSync { inner };
ProcessOne::AllSync(self)
}
warp_sync::WarpSync::Finished(success) => {
let (
new_inner,
finalized_block_runtime,
finalized_storage_code,
finalized_storage_heap_pages,
) = self.shared.transition_grandpa_warp_sync_all_forks(success);
self.inner = AllSyncInner::AllForks(new_inner);
ProcessOne::WarpSyncFinished {
sync: self,
finalized_block_runtime,
finalized_storage_code,
finalized_storage_heap_pages,
}
}
}
}
warp_sync::ProcessOne::BuildChainInformation(inner) => {
match inner.build().0 {
// TODO: errors not reported to upper layer
warp_sync::WarpSync::InProgress(inner) => {
self.inner = AllSyncInner::GrandpaWarpSync { inner };
ProcessOne::AllSync(self)
}
warp_sync::WarpSync::Finished(success) => {
let (
new_inner,
finalized_block_runtime,
finalized_storage_code,
finalized_storage_heap_pages,
) = self.shared.transition_grandpa_warp_sync_all_forks(success);
self.inner = AllSyncInner::AllForks(new_inner);
ProcessOne::WarpSyncFinished {
sync: self,
finalized_block_runtime,
finalized_storage_code,
finalized_storage_heap_pages,
}
}
}
}

@tomaka
Copy link
Contributor Author

tomaka commented Mar 27, 2023

When in the browser, this prints a lot of warnings about tasks taking exactly 16ms to poll, even very light tasks such as memory-printer. I have no idea why. EDIT: happens only on Firefox, not Chrome
It could be the case that performance.now() has a low precision, but the docs mention 5µs or 100µs, which is pretty far from 16ms: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now#security_requirements

@tomaka
Copy link
Contributor Author

tomaka commented Mar 27, 2023

It could be the case that performance.now() has a low precision

When printing the values returned by performance.now(), it seems that this is not the explanation.
The time elapsed is never actually precisely 16ms, but 16.2ms, 16.8ms, 16.4ms, etc.
I suppose that it's the browser doing something magic here and interrupting the Wasm execution for 16ms for some reason.

@tomaka
Copy link
Contributor Author

tomaka commented Mar 28, 2023

state_getKeysPaged seems to take a long time to decode the proof and run the prefix_proof system.
It seems that decoding a proof should be split into stages.

@tomaka
Copy link
Contributor Author

tomaka commented Mar 28, 2023

Verifying a finality proof should also be split into stages.

@tomaka tomaka added the blocked Progress on this issue requires something beyond our control label Dec 23, 2023
@tomaka tomaka removed the blocked Progress on this issue requires something beyond our control label Jan 3, 2024
@tomaka
Copy link
Contributor Author

tomaka commented Jan 3, 2024

I'm going to merge this PR, but not mention that an issue should be opened.

@tomaka tomaka added this pull request to the merge queue Jan 3, 2024
Merged via the queue into smol-dot:main with commit ac8980b Jan 3, 2024
22 checks passed
@tomaka tomaka deleted the warn-cpu-intensive branch January 3, 2024 13:21
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.

1 participant