Scalloc Design Decisions

TODO

  • 了解原先設計參數如何被設定
  • trace實驗的程式碼
  • 研究改變virtual span, real span size class,…對效能的影響

想法

論文當中提到可以修改MADVISE_THRESHOLD (32kB)和REUSABILITY_THRESHOLD (80%)。在src/globals.h當中,可以修改SCALLOC_REUSE_THRESHOLD,但是我還沒找到如何調整MADVISE_THRESHOLD 

Virtual span

  • 利用64-bit virtual memory address space超級大的優勢,不論required object size多大,分配出去的virtual space都是一個virtual span的大小(例如2MB)
  • 利用on-demand paging和madvise減少physical fragmentation
  • 用以下四種configuration,執行論文7.5章的實驗(Robustness for varying object sizes)
  • 1 ) scalloc
  • 2 ) scalloc-no-madvise
  • 3 ) scalloc-no-virtual-spans
  • 4 ) scalloc-no-madvise-no-virtual-spans
  • no-madvise顧名思義就是沒有使用madvise;而no-virtual-spans指的是啟用transparent huge page (THS)的kernel feature,page size可以提升至2MB,跟virtual span大小相同,等同於取消virtual span的作用(因為整個virtual span現在都要map到一個page的physical space)
  • 實驗方式: (直接修改自原文)
The y-axis shows the total time / average memory consumption spent in the allocator, i.e., the time/memory spent in malloc and free. 
The x-axis refers to intervals [2^x , 2^(x +2) ) of object sizes in bytes with 4 ≤ x ≤ 20 at increments of two. For each object size interval ACDC allocates 2^x KB of new objects, accesses the objects, and then deallocates previously allocated objects. This cycle is repeated 30 times. (at thread number = 40)
  • 論文實驗結果
  1. 開啟/關閉madvise會導致時間和記憶體空間的tradeoff: 開啟madvise會增加allocation花費的時間(syscall的時間成本),但能減少記憶體的使用量
  1. 對於small object(size < 256 bytes)和huge object(size > 1MB),是否開啟madvise不會造成影響,因為scalloc只有在處理large object的時候才會使用madvise,而分配huge object時直接使用mmap
  1. 開啟TLH
  • 注意部分
  1. 調整thread數量重新執行實驗(2,4,8,16)
  1. 利用transparent hugepage support(THS) 設定configuration


Scalable backend

用threadtest實驗證明multiple stacks per size class是有必要的(與signle stack per size class相比)
  • 論文實驗結果

Constant-time frontend

用threadtest實驗證明,比起晚一點再把空的span還給backend,scalloc積極歸還的作法再memory consumption上會有比較好的表現

參考內容

Scalloc paper 7.7