Skip to content
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

feat: martian-pipestance crate #412

Closed
wants to merge 13 commits into from

Conversation

sreenathkrishnan
Copy link
Member

  • Add a new crate that defines structs corresponding to _perf and _finalstate file. Code mostly copied from Logan's crate
  • Code to compute critical path in a pipestance.

Copy link
Collaborator

@macklin-10x macklin-10x left a comment

Choose a reason for hiding this comment

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

Nice, this looks extremely useful. Mostly minor comments.

Was the intention to provide an executable that runs this?

@@ -0,0 +1,308 @@
//!
//! Critical path in the pipestance
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to flesh out this docstring a little bit to make it clear exactly what we're talking about here.

weight_function,
))
}
pub fn compute(final_state: &FinalState, perf: &Perf, weight_function: StageWeight) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bikeshedding but this is kind of just a constructor so new is probably the conventional name.

Comment on lines +109 to +112

fn new() -> Self {
Self::default()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Providing new when we already derive Default isn't necessary IMHO.

Suggested change
fn new() -> Self {
Self::default()
}

}
}

fn _critical_path(mut self) -> CriticalPath {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Leading underscore method names aren't idiomatic in Rust; even then, this method is called and is already marked private.

Suggested change
fn _critical_path(mut self) -> CriticalPath {
fn critical_path(mut self) -> CriticalPath {

let critical_path =
CriticalPath::compute(&final_state, &perf, StageWeight::NoQueueWallTime);

println!("{:#?}", critical_path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please address the few clippy warnings?

use serde::de::DeserializeOwned;
use std::path::Path;

pub mod common;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would make more sense to move the things in common into the crate root and mark them pub(crate).

@@ -0,0 +1,26 @@
use anyhow::{Context, Result};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this crate should expose an explicit API by pub useing the relevant types/functions.

Comment on lines +6 to +8
pub mod critical_path;
pub mod final_state;
pub mod perf;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these actually be pub or should we re-export the relevant pieces?

/// A file associated with a martian pipestance such as _perf, _finalstate etc
/// that can be deserialized into a concrete type
pub trait PipestanceFile: DeserializeOwned {
fn filename() -> &'static str;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is 'static you might as well make this a const member instead of a method, unless we think this will need to be dynamically dispatched in certain cases.

Comment on lines +23 to +25
fn from_string(file_contents: String) -> Result<Self> {
Ok(serde_json::from_str(&file_contents)?)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is actually parsing JSON, it should probably be named accordingly. Also, it doesn't need to take ownership of the input.

Suggested change
fn from_string(file_contents: String) -> Result<Self> {
Ok(serde_json::from_str(&file_contents)?)
}
fn from_json(file_contents: &str) -> Result<Self> {
Ok(serde_json::from_str(file_contents)?)
}

Copy link
Member

@adam-azarchs adam-azarchs left a comment

Choose a reason for hiding this comment

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

I think it's a really bad idea to reinvent this wheel. There's a lot of subtitles that need to be gotten right. We already have code to do all of this.

It also probably shouldn't be part of the martian-lang/martian-rust repo, which is all about support for writing stage code in rust.

@@ -3,3 +3,4 @@ martian-filetypes/example.bincode
martian-filetypes/example.json
martian-filetypes/example_lazy.bincode
martian-filetypes/example_lazy.json
.DS_Store
Copy link
Member

Choose a reason for hiding this comment

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

Newline at end of file please.

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ['derive'] }
Copy link
Member

Choose a reason for hiding this comment

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

Please be consistent about which quotes to use.

@adam-azarchs
Copy link
Member

I'm going to close this PR. It doesn't belong in this repo, it doesn't product correct output, and it's redundant with existing code we have elsewhere.

@adam-azarchs adam-azarchs deleted the ksree/martian-pipestance branch September 21, 2023 20:22
@macklin-10x
Copy link
Collaborator

@adam-azarchs can you please link this PR to the aforementioned existing code for our current edification/posterity?

@sreenathkrishnan sreenathkrishnan restored the ksree/martian-pipestance branch September 21, 2023 21:45
@sreenathkrishnan
Copy link
Member Author

I'm going to close this PR. It doesn't belong in this repo, it doesn't product correct output, and it's redundant with existing code we have elsewhere.

I am okay not including the critical path code here, but it makes sense to have the struct definitions for perf and finalstate in this repo.

@adam-azarchs
Copy link
Member

@adam-azarchs
Copy link
Member

I'm going to close this PR. It doesn't belong in this repo, it doesn't product correct output, and it's redundant with existing code we have elsewhere.

I am okay not including the critical path code here, but it makes sense to have the struct definitions for perf and finalstate in this repo.

Why? Nothing using this repo should be touching top-level pipestance state like that.

@macklin-10x
Copy link
Collaborator

So I see library code there, but is there an existing executable to output the critical path from _perf data? If not, at least some guidance to how to fit the existing pieces together would probably be useful.

@adam-azarchs adam-azarchs deleted the ksree/martian-pipestance branch September 22, 2023 05:55
@adam-azarchs
Copy link
Member

Yes, but they needed a bit of maintenance; see the (private repo) PRs I sent you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants