-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add DB Read/Write Tracking to Benchmarking Pipeline #6386
Conversation
Here is an example of the output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I'll try and do another review later.
This means that we don't have to do that manual code analysis counting reads and writes right? I am curious to just see how off we were before 😁
@kianenigma This fixes the static read/write counting we were doing for extrinsics. It should give us the data so that we can create a weight formula with a "maximum" number of reads/writes the extrinsic will do. But it does not fix the on_initialize/on_finalize counting that we are doing and still need to do. |
Could I also get a review on: https://github.com/paritytech/substrate/pull/6405/files This is a PR on top of this PR to add whitelisting to to the DB Read/Write tracking |
* hardcoded whitelist * Add whitelist to pipeline * Remove whitelist pipeline from CLI, add to runtime * clean-up unused db initialized whitelist
* Add selector * add tests * debug formatter for easy formula
@@ -109,6 +151,86 @@ impl<B: BlockT> BenchmarkingState<B> { | |||
)); | |||
Ok(()) | |||
} | |||
|
|||
fn add_whitelist_to_tracker(&self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if I am wrong: by whitelisting, basically we already assume that they have been read once? there's no inherent meaning to being whitelisted other than that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this key is free to read and write to, and does not count in DB tracking.
Things like BlockNumber, the Sender Account, Events, etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, one question then: won't this cause confusion with the read-write count? Say I submit a tx that has no reads and writes. Won't the read/write count of my tx then be equal to all the whitelisted ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Either way I think it is all okay, I am just trying to make it clear for myself.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I dont increment the read/write count when I do whitelisting. So assuming nothing is actually read/written from, you will get 0 reads and 0 writes.
frame/benchmarking/src/lib.rs
Outdated
frame_support::debug::trace!(target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic); | ||
let read_write_count = $crate::benchmarking::read_write_count(); | ||
frame_support::debug::trace!(target: "benchmark", "Read/Write Count {:?}", read_write_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logs also in wasm, which is probably not desirable I think?
frame_support::debug::trace!(target: "benchmark", "Read/Write Count {:?}", read_write_count); | |
frame_support::debug::native::trace!(target: "benchmark", "Read/Write Count {:?}", read_write_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also want these logs to emit during wasm execution, which is the standard way to run these benchmarks. Per conversation in "dumb questions", this should have no overhead when the log flag is not included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave this another read and still positive about it.
@kianenigma i agree, I would like to keep it separate if possible, and start merging in this working first step |
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
For anyone reviewing, line width error here I think is unavoidable (caused by string literal in |
This PR is the first step toward adding full automation to the benchmarking pipeline.
Here, we modify the Bench DB to add an additional HashMap to track keys that have been read from and written to.
We are then able to run out bechmarks, and inspect this read/write tracker to see the number of times we do a read, repeat read, write, or repeat write.
This information is then stored as part of our BenchmarkResults output and displayed as part of the CLI.
Next steps for this is: