• T
    share_pool: Add sp_area cache · 9665ceaf
    Tang Yizhou 提交于
    ascend inclusion
    category: feature
    bugzilla: NA
    CVE: NA
    
    -------------------------------------------------
    
    Provide a free area cache for the share pool VA allocator, based on the
    algorithm used by linux mainline commit 89699605.
    
    This reduces the number of rbtree operations and linear traversals over
    the share pool extents in order to find a free area, by starting off at
    the last point that a free area was found.
    
    The free area cache is reset if areas are freed behind it, or if we are
    searching for an another area (such as DVPP 16G area) than last time.
    So allocation patterns are not changed.
    
    After this patch, the search will start from where it left off, giving
    closer to an amortized O(1).
    
    Test environment: Huawei 1951 DC (8 CPU cores) with 21G memory, no load.
    
    Test method: A single thread process first call sp_alloc() to allocate a
    specified number of 2M hugepages, then we calculate the allocation time
    when sp_alloc() another 2M hugepage. The results are in microsecond.
    
    test 1, first sp_alloc() 256  2M-hugepage, total 512M
    test 2, first sp_alloc() 512  2M-hugepage, total 1G
    test 3, first sp_alloc() 1024 2M-hugepage, total 2G
    test 4, first sp_alloc() 1536 2M-hugepage, total 3G
    test 5, first sp_alloc() 2048 2M-hugepage, total 4G
    test 6, first sp_alloc() 4096 2M-hugepage, total 8G
    test 7, first sp_alloc() 6072 2M-hugepage, total 12G
    test 8, first sp_alloc() 8192 2M-hugepage, total 16G
    
             test1         test2         test3         test4
           231   238     240   252     279   253     315   268
           242   238     247   253     282   255     326   265
           233   234     250   243     272   251     314   258
           239   224     245   246     273   261     324   262
           234   233     252   257     277   262     326   265
           225   231     243   243     279   249     325   264
           236   261     246   248     265   262     323   266
           233   238     247   246     281   259     331   265
           239   222     243   241     270   248     325   263
           241   231     239   241     335   246     321   268
    avg:  235.3  235    245.2  247    281.3 254.6    323  264.4
    res:       -             -           9.49%         18.14%
    
             test5         test6        test7         test8
           371   280     720   458    1001   629    1547   909
           369   283     691   465    1005   718    1533   903
           374   279     954   470    1003   680    1371   908
           363   279     697   457    1004   923    1375   930
           369   286     711   464    1016   683    1395  1083
           382   280     967   491    1029   695    1413  1096
           378   284     688   823    1008   689    1419   905
           376   360     921   469    1285   696    1554  1085
           374   287     896   485    1030   682    1381   902
           380   276     706   545    1286   717    1606  1097
    avg:  373.6 289.4  791.5  512.7  1066.7 717.5  1459.4 981.8
    res:     22.54%        35.52%        32.74%        32.73%
    Suggested-by: NZefan Li <lizefan@huawei.com>
    Signed-off-by: NTang Yizhou <tangyizhou@huawei.com>
    Reviewed-by: NDing Tianhong <dingtianhong@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    9665ceaf
share_pool.c 60.7 KB