-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: commit function #297
Conversation
Benchmark movements: |
Benchmark movements: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #297 +/- ##
==========================================
+ Coverage 70.65% 70.69% +0.03%
==========================================
Files 38 38
Lines 2021 2020 -1
Branches 2021 2020 -1
==========================================
Hits 1428 1428
+ Misses 524 523 -1
Partials 69 69 ☔ View full report in Codecov by Sentry. |
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.
Python side:
https://reviewable.io/reviews/starkware-industries/starkware/35461#-
Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @TzahiTaub and @yoavGrs)
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.
Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware and @yoavGrs)
crates/committer_cli/src/commands.rs
line 10 at r1 (raw file):
}; pub async fn commit(input: Input<ConfigImpl>, output_path: String) {
I don't know if it makes more sense for this to be Input
or RawInput
so I'm just raising the question @dorimedini-starkware
Code quote:
commit(input: Input<ConfigImpl>
crates/committer_cli/src/tests/regression_tests.rs
line 50 at r1 (raw file):
)) } }
IIUC the purpose of this wrapper, can't you add something like
#[cfg_attr(test, derive(Deserialize))]
above the Input
declaration and remove this struct?
Code quote:
struct CommitterInput(Input<ConfigImpl>);
impl<'de> Deserialize<'de> for CommitterInput {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
Ok(Self(
parse_input(&String::deserialize(deserializer)?).unwrap(),
))
}
}
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.
Reviewed all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @TzahiTaub, and @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
criterion.bench_function("full_committer_flow", |benchmark| { benchmark.iter(|| { // TODO(Aner, 10/07/2024): replace functions with running main.
WDYM? you want to open a subprocess that runs the committer_cli?
Code quote:
// TODO(Aner, 10/07/2024): replace functions with running main.
crates/committer_cli/src/commands.rs
line 10 at r1 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
I don't know if it makes more sense for this to be
Input
orRawInput
so I'm just raising the question @dorimedini-starkware
I think we should separate deserialization of input from the actual business logic, so I'm in favor of Input
crates/committer_cli/src/tests/regression_tests.rs
line 50 at r1 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
IIUC the purpose of this wrapper, can't you add something like
#[cfg_attr(test, derive(Deserialize))]
above theInput
declaration and remove this struct?
I also don't think you need a wrapper; just impl<'de, T: Config> Deserialize<'de> for Input<T> { ... }
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware and @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
Previously, dorimedini-starkware wrote…
WDYM? you want to open a subprocess that runs the committer_cli?
I think we discussed about calling the main
function of the committer_cli directly.
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @TzahiTaub and @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
I think we discussed about calling the
main
function of the committer_cli directly.
I don't think that's good practice; it's the entry point of the binary (only argument parsing and logger initialization). the contents of this main
is only this:
let input_string = read_from_stdin();
commit(&input_string, output_path).await;
... so if you want to include input deserialization, just extract these two lines into a function, and call it
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @TzahiTaub and @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
Previously, dorimedini-starkware wrote…
I don't think that's good practice; it's the entry point of the binary (only argument parsing and logger initialization). the contents of this
main
is only this:let input_string = read_from_stdin(); commit(&input_string, output_path).await;
... so if you want to include input deserialization, just extract these two lines into a function, and call it
... but since you're not using stdin, I see no reason to do even that
Previously, dorimedini-starkware wrote…
I think the logic is 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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @TzahiTaub, and @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
Previously, aner-starkware wrote…
I think the logic is that:
- If someone changes main (e.g., using a different commit according some flag), these changes are automatically transferred to this benchmarking, they need to be written manually.
- We're not benchmarking exactly the same thing. For example, we don't time reading from std_in (we assume that read_from_stdin() is cheap, but we might be missing something like when we wrote to file wrong).
if you want to invoke the CLI binary (i.e. subprocess?), then using main is good.
because of (1) and (2), this is probably a good idea :)
but no reason to call the main
function from within rust IMO, unless you want to pass arguments (which is the point of the main function).
Previously, dorimedini-starkware wrote…
This cannot be done without a larger refactoring, because Input is in a different crate ( |
Previously, dorimedini-starkware wrote…
I don't understand |
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @TzahiTaub and @yoavGrs)
crates/committer_cli/src/tests/regression_tests.rs
line 50 at r1 (raw file):
Previously, aner-starkware wrote…
This cannot be done without a larger refactoring, because Input is in a different crate (
committer
) than the function that deserializes it (parse_input
incommitter_cli
).
ah... right, cannot impl T for S
if both T
and S
are defined outside the current crate.
your solution (wrapping Input
in a type defined within the crate) seems like the good one
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @TzahiTaub, and @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
Previously, aner-starkware wrote…
I don't understand
I agree with you that we should run main
here.
however, you shouldn't "call main
" directly from rust code, you should be building the release binary and running it.
if this is impossible, then I don't think we can do better than the current solution: main
may change but it's logic is mainly for argument parsing anyway, which is only relevant if you run the binary...
tl;dr: I would keep the code as-is for now, and in subsequent work see if the binary itself can be run from the context of the benchmark
Previously, dorimedini-starkware wrote…
It would be good if it weren't for the annoying |
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @TzahiTaub and @yoavGrs)
crates/committer_cli/src/tests/regression_tests.rs
line 50 at r1 (raw file):
Previously, aner-starkware wrote…
It would be good if it weren't for the annoying
.0
that needs to be added...
if you add derive_more::Deref
this issue should go away usually
Benchmark movements: full_committer_flow performance regressed! |
Previously, dorimedini-starkware wrote…
How do you add it? I couldn't figure it out. But I implemented |
df58e67
to
e008a07
Compare
Benchmark movements: full_committer_flow performance regressed! |
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.
Reviewed all commit messages.
Reviewable status: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @aner-starkware, @TzahiTaub, and @yoavGrs)
crates/committer_cli/src/tests/regression_tests.rs
line 50 at r1 (raw file):
Previously, aner-starkware wrote…
How do you add it? I couldn't figure it out. But I implemented
Deref
directly, is it OK?
yes, but what I suggested doesn't work...? non-blocking
crates/committer_cli/src/tests/regression_tests.rs
line 34 at r2 (raw file):
&self.0 } }
this doesn't work?
Suggestion:
#[derive(derive_more::Deref)]
struct FactMap(Map<String, Value>);
e008a07
to
a67d9ad
Compare
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.
Reviewable status: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware, @TzahiTaub, and @yoavGrs)
crates/committer_cli/src/tests/regression_tests.rs
line 50 at r1 (raw file):
Previously, dorimedini-starkware wrote…
yes, but what I suggested doesn't work...? non-blocking
Done.
crates/committer_cli/src/tests/regression_tests.rs
line 34 at r2 (raw file):
Previously, dorimedini-starkware wrote…
this doesn't work?
Works, thanks :)
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.
Reviewed 1 of 2 files at r4.
Reviewable status: 3 of 4 files reviewed, all discussions resolved (waiting on @yoavGrs)
crates/committer_cli/benches/committer_bench.rs
line 69 at r1 (raw file):
Previously, dorimedini-starkware wrote…
I agree with you that we should run
main
here.
however, you shouldn't "callmain
" directly from rust code, you should be building the release binary and running it.
if this is impossible, then I don't think we can do better than the current solution:main
may change but it's logic is mainly for argument parsing anyway, which is only relevant if you run the binary...
tl;dr: I would keep the code as-is for now, and in subsequent work see if the binary itself can be run from the context of the benchmark
Let's try to replace it as in the TODO in another PR.
This change is