diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2017-12-07 21:19:09 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2017-12-15 10:22:03 +0000 |
commit | 556e121379494d4bed9738d9c7539ac5afc8f6f4 (patch) | |
tree | 26ac1061ee6916376bf2906b3259f5a067c7b3b3 /sal/rtl/alloc_arena.cxx | |
parent | 6d03c1367f0955900194287805324a8b4144e124 (diff) |
sal: add pre-initialization scheme for allocations.
This saves several megabytes of dirtied pages for each LOK
client of Online.
Change-Id: I425a2e7896879f0a64d71fcc0655e9e1fa1256aa
Diffstat (limited to 'sal/rtl/alloc_arena.cxx')
-rw-r--r-- | sal/rtl/alloc_arena.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index ba28f6f532f0..b8df460b4e88 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include "alloc_arena.hxx" #include "alloc_impl.hxx" @@ -990,6 +992,32 @@ void SAL_CALL rtl_arena_free ( } } +void rtl_arena_foreach (rtl_arena_type *arena, ArenaForeachFn foreachFn, void *user_data) +{ + // quantum caches + if ((arena->m_qcache_max > 0) && (arena->m_qcache_ptr != nullptr)) + { + int i, n = (arena->m_qcache_max >> arena->m_quantum_shift); + for (i = 1; i <= n; i++) + { + if (arena->m_qcache_ptr[i - 1] != nullptr) + rtl_cache_foreach (arena->m_qcache_ptr[i - 1], + foreachFn, user_data); + } + } + + /* used segments */ + for (int i = 0, n = arena->m_hash_size; i < n; i++) + { + for (rtl_arena_segment_type *segment = arena->m_hash_table[i]; + segment != nullptr; segment = segment->m_fnext) + { + foreachFn(reinterpret_cast<void *>(segment->m_addr), + segment->m_size, user_data); + } + } +} + #if defined(SAL_UNX) #include <sys/mman.h> #elif defined(SAL_W32) |