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

cli: introduce host-perf-check command #4342

Merged
merged 31 commits into from
Dec 9, 2021
Merged

Conversation

slumber
Copy link
Contributor

@slumber slumber commented Nov 21, 2021

Resolves #4196

Creating as a draft since there're couple of unresolved questions so the code needs to be polished.
But the general approach is here so we have a starting point.

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

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

A few nits, generally looks like you're on a good path.

cli/src/cli.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Show resolved Hide resolved
- Improve error handling
- Keep subcommands available in both debug and release builds
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
@slumber
Copy link
Contributor Author

slumber commented Nov 24, 2021

Does this support MacOS as well? With the M1s we will see a shift of more people building and maybe running them there as well.

We do 2 *nix things here: get $HOME env value and call gethostname from libc. As far as I know both are supposed to work the same way on MacOS and Linux. Testing it is as simple as:

cargo run --release host-perf-check

multiple times to verify it's cached.

Can only confirm it for Linux myself unfortunately.

@slumber
Copy link
Contributor Author

slumber commented Nov 24, 2021

@drahnr so we are fine with the rest? I will add erasure code test and optional run on the first launch then before marking it as ready-for-review.

@drahnr
Copy link
Contributor

drahnr commented Nov 24, 2021

@drahnr so we are fine with the rest? I will add erasure code test and optional run on the first launch then before marking it as ready-for-review.

I am rather uneasy about all the deps pulled in, either we use something more abstract, i.e. dirs or directories for this and hostname for cross paltform hostname support or ditch it altogether. Implicitly assuming nobody is build/running this on MacOS will just bring problems.

@slumber
Copy link
Contributor Author

slumber commented Nov 24, 2021

I am rather uneasy about all the deps pulled in, either we use something more abstract, i.e. dirs or directories for this and hostname for cross paltform hostname support or ditch it altogether. Implicitly assuming nobody is build/running this on MacOS will just bring problems.

dirs for home directory I suppose? On macOS and Linux it's essentially reading $HOME, so I don't think it's even worth?
As for the nix as a new dependency, it's already here in the workspace, so I thought it's better to link an existing crate than compile a new one.

cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
@bkchr
Copy link
Member

bkchr commented Nov 24, 2021

I am rather uneasy about all the deps pulled in, either we use something more abstract, i.e. dirs or directories for this and hostname for cross paltform hostname support or ditch it altogether. Implicitly assuming nobody is build/running this on MacOS will just bring problems.

dirs for home directory I suppose? On macOS and Linux it's essentially reading $HOME, so I don't think it's even worth? As for the nix as a new dependency, it's already here in the workspace, so I thought it's better to link an existing crate than compile a new one.

We have the base-path for this. We store there the dbs and other stuff.

@slumber slumber requested review from drahnr and bkchr November 24, 2021 22:06
cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
@slumber slumber requested a review from drahnr December 3, 2021 14:04
@slumber
Copy link
Contributor Author

slumber commented Dec 3, 2021

There're no constant multipliers yet, we will probably soften the limit with respect to reference values -- tbd.

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

👍

{
Err(PerfCheckError::WrongBuildType.into())
}
#[cfg(build_type = "release")]
Copy link
Member

Choose a reason for hiding this comment

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

will this work with custom profiles #4311 (comment) @bkchr?

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 don't think so, the profile should be matched with the one used for distributing the binary. If this profile changes to e.g release-lto, it should be also updated here.

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

While we don't officially support windows, I think that we at least compiled on windows all the time.

I get why you want to store the host name there, but it still feels weird.

I mean users could already run into more trouble when the just blindly copy the entire base path, because they could be slashed for equivocations etc. Especially as the check is currently optional anyway? Aka needs to be executed by the user.

cli/src/command.rs Outdated Show resolved Hide resolved
cli/src/command.rs Outdated Show resolved Hide resolved
node/test/performance-test/build.rs Outdated Show resolved Hide resolved
node/test/performance-test/src/lib.rs Outdated Show resolved Hide resolved
node/test/performance-test/src/gen_ref_constants.rs Outdated Show resolved Hide resolved
node/test/performance-test/src/gen_ref_constants.rs Outdated Show resolved Hide resolved
cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
cli/src/host_perf_check.rs Outdated Show resolved Hide resolved
cli/src/cli.rs Outdated Show resolved Hide resolved
@slumber
Copy link
Contributor Author

slumber commented Dec 4, 2021

While we don't officially support windows, I think that we at least compiled on windows all the time.

I suppose it is already broken in node/core/pvf where we import unix related stuff (sockets in particular)

I get why you want to store the host name there, but it still feels weird.

I mean users could already run into more trouble when the just blindly copy the entire base path, because they could be slashed for equivocations etc. Especially as the check is currently optional anyway? Aka needs to be executed by the user.

This is a minor effort we can afford in order to protect users from it isn't it?

@bkchr
Copy link
Member

bkchr commented Dec 5, 2021

I suppose it is already broken in node/core/pvf where we import unix related stuff (sockets in particular)

Okay, good point :)

Caching is for the case of running the check automatically on the first validator start. This is a consideration from the issue description.

Is that already done? No or?

@slumber
Copy link
Contributor Author

slumber commented Dec 5, 2021

Caching is for the case of running the check automatically on the first validator start. This is a consideration from the issue description.

Is that already done? No or?

Not yet, I'm unsure about the way of implementing it, it should always be optional so:

  • either it's always on and we allow skipping it with --no-perf-check (not cool for development environment)
  • or it's off by default and --with-perf-check enables it, but high chances people miss it or forget about it.

cc @drahnr

@drahnr
Copy link
Contributor

drahnr commented Dec 5, 2021

Given that we don't want any potential issues with node restarts, on-by-default is not an option. Online host migrations pose also an issue, when the username changes, or the hostname is changed and on next restart it experiences the delay.

That's all not good UI, and I'd prefer to ship the partial feature, having just the explicit command and post pone the rest.

@bkchr
Copy link
Member

bkchr commented Dec 5, 2021

Given that we don't want any potential issues with node restarts, on-by-default is not an option. Online host migrations pose also an issue, when the username changes, or the hostname is changed and on next restart it experiences the delay.

That's all not good UI, and I'd prefer to ship the partial feature, having just the explicit command and post pone the rest.

But then we don't need any of this caching feature? If this is something that stays optional and requires the user to run the command, why cache it?

@drahnr
Copy link
Contributor

drahnr commented Dec 5, 2021

Fully agree, deferring the caching and the resolution seems to me like the best approach. @slumber could remove the file related caching values, the rest is good to go!

@drahnr
Copy link
Contributor

drahnr commented Dec 9, 2021

bot merge

@paritytech-processbot
Copy link

Error: Checks failed for 66dfa6d

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create hostperfcheck subcommand
4 participants