Skip to content

Conversation

@tedinski
Copy link
Contributor

Description of changes:

What it says on the tin. :) Takes a 24s artificial benchmark down to under 4s to run.

  1. Mimics the same options as cargo build: --jobs or -j. Default is 1. Default with just -j is num_cpus.
  2. Conflicts with concrete-playback due to its dependence on order of harness running
  3. Currently requires --output-format=terse. And --enable-unstable of course.

There is the problem of output. We actually don't have a huge problem with interleaving output because Adrian already wrote the renderer to print one big blob instead of multiple little ones. (Nice!) However, we do still have #1711 that this exacerbates, and the "verification time" isn't really paired with an output anymore. I think this is merge-able as-is, but I do plan on an independent PR to fix up that issue tomorrow, which it might be reasonable to want merged first.

Call-outs:

Changes include:

  1. Adding a new --jobs option to kani-driver
  2. Replacing KaniSession's RefCell with a Mutex (and adding record_temporary_files)
  3. Swap a for to rayon par_iter

and that's it! It's actually a pretty simple change now. Sweet.

Testing:

  • How is this change tested? existing ci: all lines of code actually run by default, just without setting j higher than 1

  • 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.

@tedinski tedinski requested a review from a team as a code owner September 27, 2022 22:48
Copy link
Contributor

@zhassan-aws zhassan-aws left a comment

Choose a reason for hiding this comment

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

Nice! Just have a couple of comments.

ErrorKind::ArgumentConflict,
));
}
if self.jobs.is_some() && self.output_format != OutputFormat::Terse {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be more convenient to automatically switch to terse mode (which we want to switch to anyway) when jobs is specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but:

  1. The real problem is there's nowhere to put that code. e.g. this function doesn't take &mut and shouldn't.
  2. But I also felt like being annoying for the moment is fine until we stabilize, and I'm planning on fixing this issue soon as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK.

@tedinski tedinski merged commit 21ceaa2 into model-checking:main Sep 28, 2022
@tedinski tedinski deleted the parallel-runner branch September 28, 2022 19:16
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.

Can you consider this couple of comments in your next PR?

Comment on lines +236 to +239
match self.jobs {
None => Some(1), // no argument, default 1
Some(None) => None, // -j
Some(Some(x)) => Some(x), // -j=x
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it worth to create an enum for all these options? Something like:

enum JobParalellism {
    Single,
    Multiple(Option<u32>),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The double option in the args is a bit confusing imo, but is idiomatic there.

The option it returns exactly corresponds to calling num_threads on the thread pool (none means no, some means yes with this value), so I thought that was clear.

Comment on lines +416 to +421
if self.concrete_playback.is_some() && self.jobs() != Some(1) {
// Concrete playback currently embeds a lot of assumptions about the order in which harnesses get called.
return Err(Error::with_description(
"Conflicting options: --concrete-playback isn't compatible with --jobs.",
ErrorKind::ArgumentConflict,
));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't these conflicts be specified as an annotation in KaniArgs fields? Not clear to me why we handle them here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only partially. This allows -j1 to work fine for instance, and is more durable if we end up wanting to change the default to num_cpus later, but still need to require single threaded for concrete-playback. (Though hopefully we'll fix that first...)

(Basically this is a semantic check: note the () on self.jobs(), rather than just a syntactic check that conflicts would perform.)

@tedinski tedinski self-assigned this Oct 4, 2022
@tedinski tedinski added this to the Create Kani Assess tool milestone Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants