Bug 155866 - bmalloc: small and large objects should share memory
Summary: bmalloc: small and large objects should share memory
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: bmalloc (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-24 20:01 PDT by Geoffrey Garen
Modified: 2016-03-25 11:07 PDT (History)
4 users (show)

See Also:


Attachments
Patch (52.31 KB, patch)
2016-03-24 20:20 PDT, Geoffrey Garen
no flags Details | Formatted Diff | Diff
Patch (52.42 KB, patch)
2016-03-24 20:26 PDT, Geoffrey Garen
no flags Details | Formatted Diff | Diff
Patch (52.56 KB, patch)
2016-03-24 20:30 PDT, Geoffrey Garen
no flags Details | Formatted Diff | Diff
Patch (52.67 KB, patch)
2016-03-25 09:08 PDT, Geoffrey Garen
kling: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2016-03-24 20:01:48 PDT
bmalloc: small and large objects should share memory
Comment 1 Geoffrey Garen 2016-03-24 20:20:15 PDT
Created attachment 274876 [details]
Patch
Comment 2 Geoffrey Garen 2016-03-24 20:23:04 PDT
Memory:

~/OpenSource/PerformanceTests/MallocBench> ./run-malloc-benchmarks --memory_warning Baseline:~/OpenSource/WebKitBuildBaseline/Release/ Patch:~/OpenSource/WebKitBuild/Release/
                                                                                     
                                                                Baseline                               Patch                                   Δ
Peak Memory:
    reddit_memory_warning --runs 0                              13,064kB                            13,152kB                      ! 1.01x bigger
    flickr_memory_warning --runs 0                              24,264kB                            23,528kB                     ^ 1.03x smaller
    theverge_memory_warning --runs 0                            26,080kB                            25,488kB                     ^ 1.02x smaller

    <geometric mean>                                            20,220kB                            19,905kB                     ^ 1.02x smaller
    <arithmetic mean>                                           21,136kB                            20,723kB                     ^ 1.02x smaller
    <harmonic mean>                                             19,218kB                            19,015kB                     ^ 1.01x smaller

Memory at End:
    reddit_memory_warning --runs 0                               8,720kB                             8,708kB                      ^ 1.0x smaller
    flickr_memory_warning --runs 0                              11,772kB                            11,860kB                      ! 1.01x bigger
    theverge_memory_warning --runs 0                            20,652kB                            20,644kB                      ^ 1.0x smaller

    <geometric mean>                                            12,846kB                            12,871kB                       ! 1.0x bigger
    <arithmetic mean>                                           13,715kB                            13,737kB                       ! 1.0x bigger
    <harmonic mean>                                             12,094kB                            12,117kB                       ! 1.0x bigger

~/OpenSource/PerformanceTests/MallocBench> ./run-malloc-benchmarks --memory Baseline:~/OpenSource/WebKitBuildBaseline/Release/ Patch:~/OpenSource/WebKitBuild/Release/
                                                                                
                                  Baseline                Patch                    Δ
Peak Memory:
    facebook                      73,008kB             74,000kB       ! 1.01x bigger
    reddit                        13,116kB             13,236kB       ! 1.01x bigger
    flickr                        24,584kB             23,384kB      ^ 1.05x smaller
    theverge                      26,112kB             25,544kB      ^ 1.02x smaller

    <geometric mean>              28,001kB             27,657kB      ^ 1.01x smaller
    <arithmetic mean>             34,205kB             34,041kB       ^ 1.0x smaller
    <harmonic mean>               23,681kB             23,395kB      ^ 1.01x smaller

Memory at End:
    facebook                       2,716kB              3,328kB       ! 1.23x bigger
    reddit                         1,732kB              1,780kB       ! 1.03x bigger
    flickr                         2,744kB              2,808kB       ! 1.02x bigger
    theverge                       2,800kB              2,896kB       ! 1.03x bigger

    <geometric mean>               2,452kB              2,635kB       ! 1.07x bigger
    <arithmetic mean>              2,498kB              2,703kB       ! 1.08x bigger
    <harmonic mean>                2,399kB              2,558kB       ! 1.07x bigger

Memory at end goes up because of our extra metadata. (We don't free metadata.)

I think this is worth it because of the other benefits in this patch -- but I'm going to try to reduce or free metadata in a follow-up patch.
Comment 3 Geoffrey Garen 2016-03-24 20:23:18 PDT
Throughput:

~/OpenSource/PerformanceTests/MallocBench> ./run-malloc-benchmarks Baseline:~/OpenSource/WebKitBuildBaseline/Release/ Patch:~/OpenSource/WebKitBuild/Release/
                                                                                
                                                      Baseline                          Patch                              Δ
Execution Time:
    churn                                                 76ms                           74ms                 ^ 1.03x faster
    list_allocate                                         71ms                           70ms                 ^ 1.01x faster
    tree_allocate                                         72ms                           73ms                 ! 1.01x slower
    tree_churn                                            79ms                           80ms                 ! 1.01x slower
    fragment                                             131ms                          132ms                 ! 1.01x slower
    fragment_iterate                                      76ms                           76ms                               
    medium                                               191ms                          174ms                  ^ 1.1x faster
    big                                                  138ms                          137ms                 ^ 1.01x faster
    facebook                                             221ms                          231ms                 ! 1.05x slower
    reddit                                               111ms                          114ms                 ! 1.03x slower
    flickr                                               115ms                          119ms                 ! 1.03x slower
    theverge                                             144ms                          147ms                 ! 1.02x slower
    nimlang                                              118ms                          122ms                 ! 1.03x slower
    message_one                                          205ms                          209ms                 ! 1.02x slower
    message_many                                         113ms                          113ms                               
    churn --parallel                                      37ms                           36ms                 ^ 1.03x faster
    list_allocate --parallel                              65ms                           62ms                 ^ 1.05x faster
    tree_allocate --parallel                              75ms                           76ms                 ! 1.01x slower
    tree_churn --parallel                                 85ms                           83ms                 ^ 1.02x faster
    fragment --parallel                                   94ms                           94ms                               
    fragment_iterate --parallel                           31ms                           31ms                               
    medium --parallel                                    182ms                          177ms                 ^ 1.03x faster
    big --parallel                                       129ms                          130ms                 ! 1.01x slower

    <geometric mean>                                     100ms                          100ms                  ^ 1.0x faster
    <arithmetic mean>                                    111ms                          111ms                  ! 1.0x slower
    <harmonic mean>                                       88ms                           87ms                  ^ 1.0x faster
Comment 4 Geoffrey Garen 2016-03-24 20:26:31 PDT
Created attachment 274877 [details]
Patch
Comment 5 Geoffrey Garen 2016-03-24 20:28:15 PDT
Some stress tests are hit particularly hard by the extra metadata:

Memory at End:
    medium                                             4,600kB                       15,076kB                 ! 3.28x bigger
    big                                                4,584kB                       15,024kB                 ! 3.28x bigger
    fragment --parallel                                  880kB                        1,956kB                 ! 2.22x bigger
    medium --parallel                                  4,712kB                       19,856kB                 ! 4.21x bigger
    big --parallel                                     4,700kB                       38,284kB                 ! 8.15x bigger

medium and big start out with 1GB heaps and then shrink to 0, so they're more of a stress test than a benchmark of memory use in the mean.
Comment 6 Geoffrey Garen 2016-03-24 20:30:08 PDT
Created attachment 274878 [details]
Patch
Comment 7 Geoffrey Garen 2016-03-25 09:08:32 PDT
Created attachment 274909 [details]
Patch
Comment 8 Andreas Kling 2016-03-25 09:24:14 PDT
Comment on attachment 274909 [details]
Patch

r=me
Comment 9 Geoffrey Garen 2016-03-25 11:07:31 PDT
Committed r198675: <http://trac.webkit.org/changeset/198675>