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

Allow disabling logging on the command line#8638

Closed
athei wants to merge 5 commits intomasterfrom
at-disable-logging-on-benchmark
Closed

Allow disabling logging on the command line#8638
athei wants to merge 5 commits intomasterfrom
at-disable-logging-on-benchmark

Conversation

@athei
Copy link
Member

@athei athei commented Apr 19, 2021

Fixes #8611
Same for Polkadot: paritytech/polkadot#2901
bench-bot: paritytech/bench-bot#14

Currently, there is no way to compile out logging instructions from the runtime without modifying Cargo.toml files. This caused the situation in the linked issue.

In order to prevent such problems in the future we allow disabling logging on the command line by forwarding the feature from the node-cli to the runtime.

This means in order to run benchmarks properly the following command line needs to be supplied:

cargo run --release --features runtime-benchmarks,disable-logging -- benchmark

Please note that we cannot disable logging it automatically when benchmarking because our CI test supplies the runtime-benchmark feature in order to test the benchmarking code while at the same time relying on logging output.

@athei athei added A0-please_review Pull request needs code review. B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Apr 19, 2021
@kianenigma
Copy link
Contributor

if correct, it should be fixed in polkadot runtimes as well.

@athei
Copy link
Member Author

athei commented Apr 19, 2021

if correct, it should be fixed in polkadot runtimes as well.

Already on it.

@kianenigma
Copy link
Contributor

Then this is making a regression in all weights, right?

@athei
Copy link
Member Author

athei commented Apr 19, 2021

Then this is making a regression in all weights, right?

I don't think so. It was only for one specific dispatchable in pallet_contracts which had a lot of trace! stuff in a tight loop. But of course there are potentially more regressions which will be fixed by this.

@kianenigma
Copy link
Contributor

Then this is making a regression in all weights, right?

I don't think so. It was only for one specific dispatchable in pallet_contracts which had a lot of trace! stuff in a tight loop. But of course there are potentially more regressions which will be fixed by this.

phew, I thought we had artificially f-ed the weights in runtime v30, first version to have this feature.

@athei
Copy link
Member Author

athei commented Apr 20, 2021

@bkchr I moved the disable-logging flag to the frame-benchmarking crate (see latest changes in this PR) and it worked for me (the benchmarks do no longer log). Did you do something different here?

Re-requested reviews. This is now a one line PR which should make the polkadot one obsolet.

@bkchr
Copy link
Member

bkchr commented Apr 20, 2021

Yeah this works, but this also disables the logging for the node without benchmarking

@athei
Copy link
Member Author

athei commented Apr 20, 2021

Yeah this works, but this also disables the logging for the node without benchmarking

frame-benchmarking is an optional dependency which is only there if the runtime-benchmarking feature is set. So it should only disable logging when benchmarking is requested. Or am I missing something?

@bkchr
Copy link
Member

bkchr commented Apr 20, 2021

As I said in the polkadot pr, cargo and feature resolution is broken, since always

@athei
Copy link
Member Author

athei commented Apr 20, 2021

Yeah you are right. Just verified that behaviour. Rolling back the PR. I guess this is the best we can do right now.

@athei
Copy link
Member Author

athei commented Apr 20, 2021

The failing test parses logging output of the node. Because all tests are run with the runtime-benchmarks feature enabled those fail because of missing output.

So automatically activating this feature on benchmarking does not seem to be a viable path, right?

@athei athei changed the title Disable logging in runtime when enabling runtime-benchmarks Allow disabling logging on the command line Apr 21, 2021
Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

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

Not a fan of the new feature flag.

Should not possible that someone can compile their node for benchmarking and forget to disable logging such that their results are wrong.

Basti says:

I think we can optimize this by introducing a new host function that returns the max log level. Than we could prevent so call into the host for every log line, which is very likely rejected on the host

@athei
Copy link
Member Author

athei commented Apr 21, 2021

Not sure how to progress without removing those tests then.

@bkchr
Copy link
Member

bkchr commented Apr 22, 2021

#8655 this should fix it.

@athei
Copy link
Member Author

athei commented Apr 22, 2021

Superseded by #8655

@athei athei closed this Apr 22, 2021
@athei athei deleted the at-disable-logging-on-benchmark branch May 13, 2021 19:58
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. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate increased contract instrumentation costs

4 participants