Baton - flushing of thread-local memory during a long wait
authorNathan Bronson <ngbronson@fb.com>
Thu, 16 Jan 2014 05:20:03 +0000 (21:20 -0800)
committerSara Golemon <sgolemon@fb.com>
Thu, 6 Feb 2014 19:50:14 +0000 (11:50 -0800)
commit79c25e6f4a7742342347b4dc23d4e237eac2aa37
tree6e38fc2a436e31b0232da5e7d06adefb6cd9850c
parent6d89f3d33268eaa12d5eb03a4afa5caa856306c5
Baton - flushing of thread-local memory during a long wait

Summary:
This diff causes Baton to reduce a thread's memory footprint when it
blocks for an extended period (by default 5 to 7.5 seconds).  Reductions
are achieved by flushing the thread-local jemalloc caches (if jemalloc
is in use) and by calling madvise(MADV_DONTNEED) on the portion of the
thread's stack that isn't active.  Once the thread resumes execution
both of these resources will be reallocated.  Configuration is via
system-wide default.

Test Plan:
1. new unit tests
2. manual execution of existing unit tests with very low idleTimeout
3. peek and poke with gdb to observe madvise discarding the page

Reviewed By: davejwatson@fb.com

FB internal diff: D1146966
folly/Baton.h
folly/Makefile.am
folly/detail/MemoryIdler.cpp [new file with mode: 0644]
folly/detail/MemoryIdler.h [new file with mode: 0644]
folly/test/MemoryIdlerTest.cpp [new file with mode: 0644]