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 PPX derivers for lattices of tuple and record types #1095

Merged
merged 17 commits into from
Aug 7, 2024

Conversation

sim642
Copy link
Member

@sim642 sim642 commented Jun 28, 2023

This implements a big portion of #31 using my experimental ppx_easy_deriving library (EDIT: Necessary parts are now just vendored here for simplicity). The goal of the library is to provide a simpler ppx_type_directed_value-like interface with no performance penalty.
It is a revival of my two-year-old ppx-lattice branch in more polished state.

This PR changes record-valued domains to use [@@deriving lattice] and also changes the implementation of Lattice.Prod to do so. Over time, the amount of Lattice.Prod usage could be reduced by using records with meaningful field names instead.

TODO

  • Publish ppx_easy_deriving on opam. Vendored.
  • Fix opam pin in CI. Vendored.
  • Derive pretty_diff. Needs leq to define pretty_diff.
  • Check ppxlib best practices.
  • Benchmark.
  • Investigate outliers.

@sim642 sim642 added cleanup Refactoring, clean-up type-safety Type-safety improvements labels Jun 28, 2023
@sim642 sim642 self-assigned this Jun 28, 2023
@sim642 sim642 mentioned this pull request Mar 29, 2023
10 tasks
@jerhard
Copy link
Member

jerhard commented Jul 16, 2024

At the Gobcon today you mentioned that there could be another attempt at this by you on this, that would be easier to maintain. Could you have a look, whether this indeed exists?

@sim642 sim642 added this to the v2.5.0 milestone Jul 18, 2024
@sim642 sim642 marked this pull request as ready for review July 18, 2024 18:01
@michael-schwarz michael-schwarz self-requested a review July 23, 2024 11:13
@sim642
Copy link
Member Author

sim642 commented Jul 24, 2024

I did a sv-benchmarks run with 60s timeout and here's the CPU time before vs after plot:
image
On average there's no change to performance but there are some outliers (in both directions!)

All verdict changes except one are close to timeout jitter. One true changes into a quick OUT OF MEMORY which is odd.

I might try looking into some of the biggest outliers before clicking merge.

@sim642
Copy link
Member Author

sim642 commented Jul 30, 2024

All verdict changes except one are close to timeout jitter. One true changes into a quick OUT OF MEMORY which is odd.

This task is c/ldv-linux-3.4-simple/43_1a_cilled_ok_nondet_linux-43_1a-drivers--input--joystick--turbografx.ko-ldv_main0_sequence_infinite_withcheck_stateful.cil.out.i. Running with -v to see OCaml allocation stats actually shows the memory usage being lower now. This might've just been that slight changes cause GC to trigger a bit later now and there's a moment with higher memory usage.

@sim642
Copy link
Member Author

sim642 commented Jul 30, 2024

On average there's no change to performance but there are some outliers (in both directions!)

One of the biggest improvements (2× in time) is on /c/hardware-verification-bv/btor2c-lazyMod.driving_phils.5.prop1-func-interl.c where also the allocated memory amount is halved. This is actually orthogonal to the new deriver: it's just because in this PR I've also replaced the IntDomain hash function with a derived one, which seems to have this huge effect. Maybe the hand-written one has too many collisions or temporary stuff.

In others, e.g. c/goblint-regression/28-race_reach_71-funloop_racing.i there's a slowdown 29s → 36s, which seems to be due to the same hash change. So there seems to be surprisingly large variation in runtime from a single hash function. This might need a separate investigation.

@sim642 sim642 merged commit 8109985 into master Aug 7, 2024
21 checks passed
@sim642 sim642 deleted the ppx-lattice-easy branch August 7, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Refactoring, clean-up type-safety Type-safety improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants