Skip to content

Performance regression (possibly involving Result) #1766

Closed

Description

@aaronbembenek-aws

I encountered a 100x slowdown (from 3 seconds to 700+ seconds) on a Firecracker proof I've been working on (used as an example in #1723). The offending commit is the toolchain upgrade to nightly-2022-09-13 (07092de).

I suspect that the reason is that Result used to be represented as a struct, but is now represented as a union. Consider this function:

fn do_something() -> Result<u32, &'static str> {
    if kani::any() {
        Ok(42)
    } else {
        Err("woops")
    }
}

Before, the GotoC signature was:

struct std::result::Result<u32, &str> do_something(void);

Afterwards, the GotoC signature was:

union std::result::Result<u32, &str> do_something(void);

The toolchain upgrade involved changes to the niche optimization, so it could be related to that.

Activity

  1. added
    [E] Performance
    T-High Priority
    on Oct 7, 2022
  2. moved this to In Progress in Kani 0.17on Dec 6, 2022
  3. aaronbembenek-aws commented on Dec 10, 2022

    @aaronbembenek-aws
    ContributorAuthor

    I believe that this issue has been resolved with changes to CBMC, but waiting on #1962 to confirm.

    The Firecracker proof that witnessed this regression is available here. With the METRICS statements in the parse_put_vsock function enabled (they're commented out by default), running the proof harness with Kissat used to take ~170 seconds before the regression.

  4. tautschnig commented on Dec 13, 2022

    @tautschnig
    Member

    Do you strictly need to use Kissat? Would CBMC built with CaDiCaL as solver not have fairly similar performance? (I would actually expect Kani's performance with an external SAT solver to be pretty poor, because it will repeatedly have to solve a very similar problem, but will always do so from scratch.)

  5. aaronbembenek-aws commented on Dec 13, 2022

    @aaronbembenek-aws
    ContributorAuthor

    Using CBMC built with CaDiCaL should suffice. I've run into some linking issues when trying to build this, but I'll post results once I have them. I did try CBMC built with glucose, and it takes 470 seconds (about the same as using CBMC's default build).

  6. tautschnig commented on Dec 13, 2022

    @tautschnig
    Member

    Using CBMC built with CaDiCaL should suffice. I've run into some linking issues when trying to build this, but I'll post results once I have them. I did try CBMC built with glucose, and it takes 470 seconds (about the same as using CBMC's default build).

    Let me know what those issues are, CaDiCaL builds ought to work fine out of the box.

  7. moved this to In Progress in Kani 0.18on Dec 13, 2022
  8. aaronbembenek-aws commented on Dec 13, 2022

    @aaronbembenek-aws
    ContributorAuthor

    Good news: things are quite fast using CBMC built with CaDiCAL (~20s), so we can close this issue.

    Let me know what those issues are, CaDiCaL builds ought to work fine out of the box.

    I don't think there was anything CBMC specific here - just common problems with trying to build C++ projects on Mac that were resolved by explicitly installing a compiler with Homebrew instead of using the system one.

  9. Repository owner moved this from In Progress to Done in Kani 0.17on Dec 13, 2022
  10. Repository owner moved this from In Progress to Done in Kani 0.18on Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

T-High Priority[E] Performance

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions