Skip to content
Snippets Groups Projects
  • Cyrill Gorcunov's avatar
    553dc562
    lib/core/fiber: Relax stack memory usage on recycle · 553dc562
    Cyrill Gorcunov authored
    We want to detect a situation where task in fiber is too eager for
    stack memory and relax rss usage in such case. For this sake upon
    stack creation we put 8 marks near 64K bound (such params allows us
    to fill ~1/4 of a page, which seem reasonable but we might change
    this params with time).
    
    Once stack get recycled we investigate the marks and if they were
    overwritten we drop all pages behind to relax memory usage (if OS
    supports madvise syscall).
    
    Another important moment is that we're marking the whole stack
    as not present thus if fiber never stepped over 64K limit the
    marks will be in tact and it means the fibers are light ones
    there won't be much #pf in future.
    
    Later we plan to implement an intelligent fiber scheduling
    considering how many memory fibers consume in average.
    
    @locker:
     - fix watermark page alignment for grow-up stack
     - improve MADV_DONTNEED check
     - clean up code and elaborate comments
     - add test case to unit/fiber
     - fix unit/guard test
    
    Follow-up #3418
    553dc562
    History
    lib/core/fiber: Relax stack memory usage on recycle
    Cyrill Gorcunov authored
    We want to detect a situation where task in fiber is too eager for
    stack memory and relax rss usage in such case. For this sake upon
    stack creation we put 8 marks near 64K bound (such params allows us
    to fill ~1/4 of a page, which seem reasonable but we might change
    this params with time).
    
    Once stack get recycled we investigate the marks and if they were
    overwritten we drop all pages behind to relax memory usage (if OS
    supports madvise syscall).
    
    Another important moment is that we're marking the whole stack
    as not present thus if fiber never stepped over 64K limit the
    marks will be in tact and it means the fibers are light ones
    there won't be much #pf in future.
    
    Later we plan to implement an intelligent fiber scheduling
    considering how many memory fibers consume in average.
    
    @locker:
     - fix watermark page alignment for grow-up stack
     - improve MADV_DONTNEED check
     - clean up code and elaborate comments
     - add test case to unit/fiber
     - fix unit/guard test
    
    Follow-up #3418