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

Add initial support for Litani build and dashboard. #389

Merged
merged 6 commits into from
Aug 9, 2021

Conversation

bdalrhm
Copy link
Contributor

@bdalrhm bdalrhm commented Aug 5, 2021

Description of changes:

This PR adds initial support for Litani build. We use Litani to run RMC on the examples and generate an HTML dashboard with the results.

Resolved issues:

Resolves #384 & #392

Call-outs:

  • src/tools/dashboard/src/util.rs contains a lot of duplicated code from compiletest. Consider reconciling with compiletest or porting all of our test suites to Litani.
  • We run the examples in the reference twice to generate the terminal dashboard and Litani's dashboard. Consider using run.json to generate the terminal dashboard.
  • The default names stages Litani uses (build, test, and report) does not match with our stages (check, codegen, verification). Switch to custom stage names when Litani adds support for that.

Testing:

  • How is this change tested?
    • The generated HTML dashboard closely matches the terminal version.
  • Is this a refactor change?
    • No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@bdalrhm bdalrhm self-assigned this Aug 5, 2021
@bdalrhm bdalrhm requested review from adpaco-aws and karkhaz August 5, 2021 13:50
Comment on lines +89 to +101
for command in self.spawned_commands.iter_mut() {
command.wait().unwrap();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if they do not terminate? Are we using timeouts when invoking litani?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not running the tests here. We're only adding them as jobs for Litani to run later. This command takes less around 0.1 second. However, the run-build command after this may not terminate, but that's a good hint that we're missing a --unwind argument somewhere.

Copy link
Contributor

@adpaco-aws adpaco-aws Aug 5, 2021

Choose a reason for hiding this comment

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

Can we add a timeout to run-build then? Litani should have that feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can do. Currently, individual jobs can take a --timeout flag which is often more useful, but added an issue for this.

Comment on lines 57 to 68
command.get_envs().filter(|(k, _)| !job_envs.contains_key(k)).fold(
&mut new_envs,
|fmt, (k, v)| {
fmt.write_fmt(format_args!(
"{}=\"{}\" ",
k.to_str().unwrap(),
v.unwrap().to_str().unwrap()
))
.unwrap();
fmt
},
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this block of code just pretty-printing a HashMap struct? There must be a more idiomatic way of doing that.

Copy link
Contributor Author

@bdalrhm bdalrhm Aug 5, 2021

Choose a reason for hiding this comment

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

hmm... I haven't found anything online. I could use flat_map instead of fold if you prefer that.

// SPDX-License-Identifier: Apache-2.0 OR MIT
//! The types and procedures in this modules are similar to the ones in
//! `compiletest`. Consider using `Litani` to run the test suites.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should import these types and procedures instead. Or add them here and import in compiletest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened an issue for this.

Comment on lines +12 to +19
/// A buffer of the `spawn`ed Litani jobs so far. `Litani` takes some time
/// to execute each `add-job` command and executing thousands of them
/// sequentially takes a considerable amount of time. To speed up the
/// execution of those commands, we spawn those commands sequentially (as
/// normal). However, instead of `wait`ing for each process to terminate,
/// we add its handle to a buffer of the `spawn`ed processes and continue
/// with our program. Once we are done adding jobs, we wait for all of them
/// to terminate before we run the `run-build` command.
Copy link
Contributor

Choose a reason for hiding this comment

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

We can just say that we spawn all litani asynchronously and wait for them to terminate.

.gitmodules Outdated Show resolved Hide resolved
/// we add its handle to a buffer of the `spawn`ed processes and continue
/// with our program. Once we are done adding jobs, we wait for all of them
/// to terminate before we run the `run-build` command.
spawned_commands: Vec<Child>,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's actually safe to run multiple litani add-job in parallel. Have you considered doing something like that? If there's a way in rust to launch some kind of thread pool, you could have a bunch of worker threads that all call litani add-job concurrently. We do this in other projects, but using python.

No need to do this for this PR, it could be something we do later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what spawned_commands is for 🙂. We spawn the litani add-job processes sequentially. But the processes themselves run concurrently. I experimented with spawning those processes concurrently, but did not see any performance improvements as it takes much longer to execute and terminate litani add-job processes concurrently than it takes spawn them and parse all tests sequentially (it's Rust after all 😉).

Comment on lines +89 to +101
for command in self.spawned_commands.iter_mut() {
command.wait().unwrap();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can do. Currently, individual jobs can take a --timeout flag which is often more useful, but added an issue for this.

src/tools/dashboard/src/litani.rs Show resolved Hide resolved
fmt
});
job.args([
"add-job",
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're using inputs and outputs as I suggest below, I suggest also passing in --phony-outputs; this is available in the develop branch of Litani, we'll release it probably next week

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's SO COOOL!!!

src/tools/dashboard/src/util.rs Show resolved Hide resolved
src/tools/dashboard/src/util.rs Show resolved Hide resolved
src/tools/dashboard/src/util.rs Show resolved Hide resolved
@bdalrhm bdalrhm linked an issue Aug 6, 2021 that may be closed by this pull request
@bdalrhm bdalrhm requested review from adpaco-aws and karkhaz August 6, 2021 15:58
Copy link
Contributor

@adpaco-aws adpaco-aws 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 is better to insert links instead of referencing issue numbers. This way developers can just click on them.

src/tools/dashboard/src/util.rs Outdated Show resolved Hide resolved
"--ok-returns",
&exit_status.to_string(),
"--timeout",
"10",
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid hard-coding here by making timeout a parameter of add_job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Changed the timeout value for check and codegen steps to 1 sec.

src/tools/dashboard/src/util.rs Outdated Show resolved Hide resolved
src/tools/dashboard/src/util.rs Outdated Show resolved Hide resolved
@bdalrhm bdalrhm changed the base branch from main-154-2021-08-02 to main-154-2021-08-06 August 6, 2021 18:58
@bdalrhm bdalrhm requested a review from adpaco-aws August 6, 2021 18:58
@bdalrhm bdalrhm merged commit 3d4a86e into model-checking:main-154-2021-08-06 Aug 9, 2021
adpaco-aws added a commit that referenced this pull request Aug 17, 2021
* Add initial support for Litani build and dashboard.

* Add panic message and issue numbers.

* Add a timeout for Litani jobs.

* Add depencies between jobs.

* Add links to issues.

Co-authored-by: Adrian Palacios <[email protected]>
adpaco-aws added a commit that referenced this pull request Aug 24, 2021
* Add initial support for Litani build and dashboard.

* Add panic message and issue numbers.

* Add a timeout for Litani jobs.

* Add depencies between jobs.

* Add links to issues.

Co-authored-by: Adrian Palacios <[email protected]>
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 22, 2022
* Add initial support for Litani build and dashboard.

* Add panic message and issue numbers.

* Add a timeout for Litani jobs.

* Add depencies between jobs.

* Add links to issues.

Co-authored-by: Adrian Palacios <[email protected]>
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 25, 2022
* Add initial support for Litani build and dashboard.

* Add panic message and issue numbers.

* Add a timeout for Litani jobs.

* Add depencies between jobs.

* Add links to issues.

Co-authored-by: Adrian Palacios <[email protected]>
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
* Add initial support for Litani build and dashboard.

* Add panic message and issue numbers.

* Add a timeout for Litani jobs.

* Add depencies between jobs.

* Add links to issues.

Co-authored-by: Adrian Palacios <[email protected]>
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Add initial support for Litani build and dashboard.

* Add panic message and issue numbers.

* Add a timeout for Litani jobs.

* Add depencies between jobs.

* Add links to issues.

Co-authored-by: Adrian Palacios <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants