Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[WIP] Pvf host prechecking support #4101

Closed
wants to merge 3 commits into from

Conversation

slumber
Copy link
Contributor

@slumber slumber commented Oct 18, 2021

Resolves #3857

@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Oct 18, 2021
Copy link
Contributor

@pepyakin pepyakin left a comment

Choose a reason for hiding this comment

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

quick glance

node/core/pvf/src/precheck/queue.rs Outdated Show resolved Hide resolved
node/core/pvf/src/precheck/worker.rs Outdated Show resolved Hide resolved
node/core/pvf/src/host.rs Outdated Show resolved Hide resolved
@slumber slumber requested a review from pepyakin October 21, 2021 13:16
@@ -22,7 +22,7 @@ use std::{fmt, sync::Arc};
/// A struct that carries code of a parachain validation function and it's hash.
///
/// Should be cheap to clone.
#[derive(Clone)]
#[derive(Clone, PartialEq, Eq)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need PartialEq and Eq impls here?

The implementation for PartialEq will be derived based on Vec's which implies byte-wise comparsion, which is really not efficient and also not required since we have the hash at hand.

Copy link
Contributor Author

@slumber slumber Oct 21, 2021

Choose a reason for hiding this comment

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

ToPool implements it (for testing purpose I guess), one of events now contains Pvf, that's why I derived it. A subject to change of course.

@@ -265,6 +291,7 @@ async fn run(
cleanup_pulse_interval,
artifact_ttl,
mut artifacts,
mut precheck_statuses,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think passing this struct as a parameter doesn't really make sense: the only thing caller does is just creates a new instance.

Let's move it inside the body making it a local.

/// Failed to precheck the PVF due to the time limit.
TimedOut,
/// Failed to precheck the PVF due to the memory limit.
MemoryLimitReached,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we using this anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, I don't know yet how to catch this kind of error, even though there's a memory limit in executor configuration, I don't see any public interface that tells you preparation exceeded it

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I think that's irrelevant.

The memory limit in the executor is only for the execution. There is no option to limit the memory amount consumed by the compilation. That's actually one of the reasons we do it in a separate process in the first place.

use std::collections::hash_map::Entry;

if let Some(_) = artifacts.artifact_state(&pvf.as_artifact_id()) {
let _ = result_sender.send(Ok(()));
Copy link
Contributor

Choose a reason for hiding this comment

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

As the things stand now, we only note whether we processed the artifact or not in artifacts. We do not record anything regarding the preparation outcome. It will also return Some in case the artifact is going through preparation.

Thus this will incorrectly report an Ok when the artifact is in fact preparing or prepared with an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a PVF actually got to the point of preparing, doesn't it mean it's considered prechecked?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, kind of.

That is, under the current model, the owner of the PVF validation host will only send a command to execute PVF, if the PVF was approved on-chain. That assumption is a bit too fragile to rely upon though IMO.

},
}
})
.await
}

pub async fn start_precheck_work(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we get away with only single code path?

From a glance, I can see that the pre-checking code path doesn't persist the resulting artifact. Which is acceptable, but not necessary.

It's important that it's not the otherway around actually: e.g. assuming we run preparation with parallel_compilation on, if pre-checking reused the result then its result will be skewed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code path is the same for them, the actual worker process accepts both types of tasks, it's that futures attached to the worker stream are different, trying to fit them in a single function would be a complete mess.
From the point of memory consumption it makes no difference, on the other hand having two methods handling separate tasks improves readability.

Probably I didn't quite understand you?

@slumber
Copy link
Contributor Author

slumber commented Oct 21, 2021

Closed in favor of #4123

@slumber slumber closed this Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-in_progress Pull request is in progress. No review needed at this stage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation host support for pre-checking
2 participants