You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Poor performance scaling for a simple program involving String push/pop #2015
T-CBMCIssue related to an existing CBMC issue[C] Feature / EnhancementA new feature request or enhancement to an existing feature.[E] PerformanceTrack performance improvement (Time / Memory / CPU)
Verification scales poorly on a simple program involving Stringpush and pop even when the String is created using with_capacity:
#[kani::proof]#[kani::unwind(2)]fnmain(){constN:usize = 1;letmut s = String::with_capacity(50);let chars:[char;N] = kani::any();for c in chars {
s.push(c);}for c in chars.iter().rev(){assert_eq!(s.pop(),Some(*c));}}
Verification time and memory usage is as follows:
# of pushes/pops
Verification time (s)
Memory usage (MB)
1
4
181
2
13
663
3
61
1872
4
225
4430
5
882
9145
6
2834
17746
In comparison, performance scaling is much better on a similar program with vector push/pop:
#[kani::proof]#[kani::unwind(2)]fnmain(){constN:usize = 1;letmut v = Vec::with_capacity(10);let arr:[i32;N] = kani::any();for x in arr {
v.push(x);}for x in arr.iter().rev(){assert_eq!(v.pop(),Some(*x));}}
# of pushes/pops
Verification time (s)
Memory usage (MB)
1
0.9
54
2
1.1
64
3
1.3
73
4
1.5
83
5
1.7
94
6
2.0
104
7
2.2
114
So it seems that the UTF-8 encoding of strings significantly complicates the formulas.
T-CBMCIssue related to an existing CBMC issue[C] Feature / EnhancementA new feature request or enhancement to an existing feature.[E] PerformanceTrack performance improvement (Time / Memory / CPU)
Activity
tautschnig commentedon Apr 20, 2023
See #2302 (comment).