From cfdbbc84dec8a82f69d55fbfac2edb811f94bfb7 Mon Sep 17 00:00:00 2001 From: trasz Date: Wed, 14 Nov 2018 13:06:48 +0000 Subject: [PATCH] Pick 57553c3b1a5592dc4c03f3c6831d9b794e523865 from upstream: Avoid touching all pages in extent_recycle for debug build. We may have a large number of pages with *zero set (since they are populated on demand). Only check the first page to avoid paging in all of them. This makes it easy to compare performance with and without 'retain:true'. Discussed with: jasone Obtained from: Qi Wang MFC after: 2 weeks Sponsored by: DARPA, AFRL --- contrib/jemalloc/src/extent.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/jemalloc/src/extent.c b/contrib/jemalloc/src/extent.c index 09d6d771817f..019aa47a6be5 100644 --- a/contrib/jemalloc/src/extent.c +++ b/contrib/jemalloc/src/extent.c @@ -1113,14 +1113,15 @@ extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks, if (*zero) { void *addr = extent_base_get(extent); - size_t size = extent_size_get(extent); if (!extent_zeroed_get(extent)) { + size_t size = extent_size_get(extent); if (pages_purge_forced(addr, size)) { memset(addr, 0, size); } } else if (config_debug) { size_t *p = (size_t *)(uintptr_t)addr; - for (size_t i = 0; i < size / sizeof(size_t); i++) { + /* Check the first page only. */ + for (size_t i = 0; i < PAGE / sizeof(size_t); i++) { assert(p[i] == 0); } }