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

High memory consumption for interior mutability function contract test #3611

Open
zhassan-aws opened this issue Oct 17, 2024 · 0 comments
Open
Labels
[C] Bug This is a bug. Something isn't working. [E] Performance Track performance improvement (Time / Memory / CPU)

Comments

@zhassan-aws
Copy link
Contributor

This test: https://github.com/model-checking/kani/blob/main/tests/expected/function-contract/interior-mutability/whole-struct/refcell.rs

using the following command line invocation:

kani refcell.rs -Zfunction-contracts

with Kani version: 041beda

consumes more than 9 GB of memory and the solver instance includes a huge number of clauses/literals even though the size of the program expression is fairly small (~2K):

$ /usr/bin/time --verbose kani refcell.rs -Zfunction-contracts
...
Running with 16 object bits, 48 offset bits (user-specified)
Starting Bounded Model Checking
Runtime Symex: 0.0773892s
size of program expression: 2181 steps
slicing removed 1354 assignments
Generated 195 VCC(s), 37 remaining after simplification
Runtime Postprocess Equation: 0.000353808s
Passing problem to propositional reduction
converting SSA
Runtime Convert SSA: 19.0731s
Running propositional reduction
Post-processing
Runtime Post-process: 6.2e-06s
Solving with CaDiCaL 2.0.0
16918466 variables, 42087481 clauses
SAT checker: instance is SATISFIABLE
Runtime Solver: 4.70032s
Runtime decision procedure: 23.9866s
Running propositional reduction
Solving with CaDiCaL 2.0.0
16918467 variables, 42087482 clauses
SAT checker: instance is SATISFIABLE
Runtime Solver: 0.645725s
Runtime decision procedure: 0.860385s
Running propositional reduction
Solving with CaDiCaL 2.0.0
16918468 variables, 42087483 clauses
SAT checker: instance is SATISFIABLE
Runtime Solver: 0.643113s
Runtime decision procedure: 0.859491s
Running propositional reduction
Solving with CaDiCaL 2.0.0
16918469 variables, 42087484 clauses
SAT checker: instance is UNSATISFIABLE
Runtime Solver: 0.000550312s
Runtime decision procedure: 0.175352s
...

VERIFICATION:- SUCCESSFUL
Verification Time: 30.182495s

Complete - 1 successfully verified harnesses, 0 failures, 1 total.
	Command being timed: "kani refcell.rs -Zfunction-contracts"
	User time (seconds): 25.33
	System time (seconds): 8.08
	Percent of CPU this job got: 101%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:33.07
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 9200340
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 0
	Minor (reclaiming a frame) page faults: 3457986
	Voluntary context switches: 1824
	Involuntary context switches: 99
	Swaps: 0
	File system inputs: 0
	File system outputs: 5496
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0
@zhassan-aws zhassan-aws added [C] Bug This is a bug. Something isn't working. [E] Performance Track performance improvement (Time / Memory / CPU) labels Oct 17, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 28, 2024
This is a mitigation for #3611 till we determine the reason for the high
memory consumption. Since this test frequently fails due to running out
of memory when running locally, reducing the number of object bits.

Without this change, memory usage is ~9 GB:
```
SUMMARY:
 ** 0 of 182 failed (1 unreachable)

VERIFICATION:- SUCCESSFUL
Verification Time: 30.51689s

Complete - 1 successfully verified harnesses, 0 failures, 1 total.
        Command being timed: "kani refcell.rs -Zfunction-contracts"
        User time (seconds): 25.17
        System time (seconds): 8.07
        Percent of CPU this job got: 100%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:33.20
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 9196056
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 3464218
        Voluntary context switches: 1834
        Involuntary context switches: 128
        Swaps: 0
        File system inputs: 0
        File system outputs: 5400
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0
```
and with this change, it's about ~600MB:
```

VERIFICATION:- SUCCESSFUL
Verification Time: 2.0234118s

Complete - 1 successfully verified harnesses, 0 failures, 1 total.
        Command being timed: "kani refcell.rs -Zfunction-contracts --enable-unstable --cbmc-args --object-bits 12"
        User time (seconds): 3.82
        System time (seconds): 0.92
        Percent of CPU this job got: 100%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.72
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 613636
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 60
        Minor (reclaiming a frame) page faults: 289631
        Voluntary context switches: 1882
        Involuntary context switches: 16
        Swaps: 0
        File system inputs: 11832
        File system outputs: 5400
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0
```

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working. [E] Performance Track performance improvement (Time / Memory / CPU)
Projects
None yet
Development

No branches or pull requests

1 participant