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

Scrub deallocations before reallocation. #609

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

mjp41
Copy link
Member

@mjp41 mjp41 commented Mar 31, 2023

This adds an additional mitigation to scrub allocations before they are reallocated. We should do perf analysis before we decide if this is an always on mitigation.

@mjp41 mjp41 requested a review from nwf-msr March 31, 2023 19:15
@mjp41
Copy link
Member Author

mjp41 commented Apr 1, 2023

So I ran a single pass of mimalloc-bench on this

#------------------------------------------------------------------
# test    alloc   time  rss    user  sys  page-faults page-reclaims
cfrac       sn-m0 06.36 3312 6.35 0.00 0 434
cfrac       sn-m12 06.61 3560 6.61 0.00 0 510
cfrac       sn-m13 06.87 3648 6.86 0.00 0 511
cfrac       sn-chk 06.84 3736 6.84 0.00 0 511
espresso    sn-m0 05.18 6248 5.13 0.02 5 656
espresso    sn-m12 05.26 14708 5.24 0.02 0 722
espresso    sn-m13 05.46 14816 5.45 0.01 0 725
espresso    sn-chk 05.50 14672 5.48 0.01 0 717
barnes      sn-m0 02.87 65552 2.84 0.02 2 2839
barnes      sn-m12 02.85 65868 2.84 0.01 0 2864
barnes      sn-m13 02.88 65872 2.86 0.02 0 2865
barnes      sn-chk 02.86 65676 2.85 0.01 0 2848
redis       sn-m0 4.299 8328 0.20 0.02 18 1273
redis       sn-m12 4.380 11868 0.19 0.03 0 1684
redis       sn-m13 4.519 13680 0.17 0.06 0 2133
redis       sn-chk 4.540 13636 0.18 0.05 0 2129
leanN       sn-m0 25.37 554224 97.48 0.72 166 13964
leanN       sn-m12 26.70 729428 103.30 0.90 0 14205
leanN       sn-m13 26.78 701400 99.95 1.68 0 372164
leanN       sn-chk 28.45 681480 108.82 1.71 0 370780
larsonN-sized sn-m0 1.224 921164 357.46 1.17 0 75204
larsonN-sized sn-m12 1.448 948324 355.82 1.40 0 69590
larsonN-sized sn-m13 7.780 880144 350.75 1.28 0 44900
larsonN-sized sn-chk 8.642 851820 352.24 1.29 0 44474
mstressN    sn-m0 01.92 1575824 44.34 2.23 0 30869
mstressN    sn-m12 02.46 1620004 44.79 3.21 0 39147
mstressN    sn-m13 09.60 1362696 51.99 61.56 0 7511285
mstressN    sn-chk 09.63 1381832 50.47 65.04 0 7505614
rptestN     sn-m0 2.755 1042792 31.96 5.00 5 36736
rptestN     sn-m12 3.049 1026724 37.92 4.92 5 36158
rptestN     sn-m13 4.507 964600 53.84 5.08 0 31708
rptestN     sn-chk 4.813 846072 57.91 4.91 2 35348
gs          sn-m0 01.94 48208 1.12 0.07 213 1835
gs          sn-m12 01.16 54212 1.13 0.02 0 1940
gs          sn-m13 01.41 50948 1.23 0.17 0 73796
gs          sn-chk 01.44 50920 1.26 0.17 0 73672
lua         sn-m0 06.37 97692 4.92 0.54 300 147891
lua         sn-m12 05.54 103520 4.97 0.56 0 154032
lua         sn-m13 05.76 104196 5.13 0.62 0 174304
lua         sn-chk 05.72 103868 5.10 0.61 0 175901
alloc-test1 sn-m0 03.64 13968 3.62 0.01 0 1352
alloc-test1 sn-m12 03.74 16128 3.73 0.00 0 1405
alloc-test1 sn-m13 03.92 15068 3.92 0.00 0 1406
alloc-test1 sn-chk 03.92 15192 3.92 0.00 0 1403
alloc-testN sn-m0 03.66 21408 56.72 0.02 0 7061
alloc-testN sn-m12 03.73 21700 58.48 0.03 0 9359
alloc-testN sn-m13 03.83 21384 61.08 0.02 0 9312
alloc-testN sn-chk 03.91 21328 61.33 0.01 0 9370
sh6benchN   sn-m0 00.13 299380 1.67 0.30 0 39842
sh6benchN   sn-m12 00.55 492468 30.33 0.29 0 47556
sh6benchN   sn-m13 00.33 511348 12.85 0.34 0 51693
sh6benchN   sn-chk 00.32 523556 11.77 0.34 0 54782
sh8benchN   sn-m0 00.20 300464 4.86 0.18 0 16619
sh8benchN   sn-m12 00.43 459880 8.68 0.63 0 20091
sh8benchN   sn-m13 01.89 787908 47.79 4.51 0 228719
sh8benchN   sn-chk 01.63 818524 31.11 4.19 0 216240
xmalloc-testN sn-m0 0.202 262404 187.86 45.13 0 39989
xmalloc-testN sn-m12 0.268 299488 195.74 12.09 4 41547
xmalloc-testN sn-m13 0.282 314124 217.25 9.41 0 44752
xmalloc-testN sn-chk 0.282 305172 218.47 9.60 0 46864
cache-scratch1 sn-m0 01.42 3920 1.42 0.00 0 280
cache-scratch1 sn-m12 01.41 3876 1.41 0.00 0 283
cache-scratch1 sn-m13 01.41 3900 1.41 0.00 0 278
cache-scratch1 sn-chk 01.42 3984 1.42 0.00 0 282
cache-scratchN sn-m0 00.05 4412 3.31 0.00 0 588
cache-scratchN sn-m12 00.05 4664 3.30 0.01 0 653
cache-scratchN sn-m13 00.05 4428 3.26 0.01 0 650
cache-scratchN sn-chk 00.05 4764 3.26 0.01 0 655
glibc-simple sn-m0 01.64 2460 1.63 0.00 0 291
glibc-simple sn-m12 02.41 2616 2.41 0.00 0 316
glibc-simple sn-m13 02.27 2604 2.27 0.00 0 329
glibc-simple sn-chk 02.27 2620 2.27 0.00 0 325
glibc-thread sn-m0 .339 63960 141.38 0.09 69 20390
glibc-thread sn-m12 .394 282480 138.76 0.35 0 43582
glibc-thread sn-m13 .456 282524 138.78 0.24 0 42587
glibc-thread sn-chk .457 282576 137.92 0.27 0 41156
rocksdb     sn-m0 05.29 102108 3.91 1.53 86 2398
rocksdb     sn-m12 05.21 107144 3.87 1.67 0 2580
rocksdb     sn-m13 05.26 100960 4.05 1.59 0 20659
rocksdb     sn-chk 05.38 99392 4.15 1.63 0 20808

So m0 is not mitigations, m12 is everything except free scrub and guarded mempcy, m13 has free scrub, and sn-chk is all the checks. This looks a bit pricey in places to turn on always. But worth having as an option.

@nwf
Copy link
Collaborator

nwf commented Oct 18, 2024

WesZero. Hah! ❤️

@mjp41
Copy link
Member Author

mjp41 commented Oct 18, 2024

WesZero. Hah! ❤️

Sadly for Larson it goes slower. But I think Larson is mostly untouched allocations below the size of a page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants