< prev index next >
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Print this page
rev 59422 : 8245754: Shenandoah: ditch ShenandoahAlwaysPreTouch
Reviewed-by: XXX
rev 59423 : 8245755: Shenandoah: missing logging for CWR Roots
Reviewed-by: XXX
rev 59424 : 8245757: Shenandoah: AlwaysPreTouch should not disable heap resizing or uncommits
Reviewed-by: XXX
*** 108,118 ****
_page_size(page_size) {}
virtual void work(uint worker_id) {
ShenandoahHeapRegion* r = _regions.next();
while (r != NULL) {
! os::pretouch_memory(r->bottom(), r->end(), _page_size);
r = _regions.next();
}
}
};
--- 108,120 ----
_page_size(page_size) {}
virtual void work(uint worker_id) {
ShenandoahHeapRegion* r = _regions.next();
while (r != NULL) {
! if (r->is_committed()) {
! os::pretouch_memory(r->bottom(), r->end(), _page_size);
! }
r = _regions.next();
}
}
};
*** 134,144 ****
while (r != NULL) {
size_t start = r->index() * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
size_t end = (r->index() + 1) * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
assert (end <= _bitmap_size, "end is sane: " SIZE_FORMAT " < " SIZE_FORMAT, end, _bitmap_size);
! os::pretouch_memory(_bitmap_base + start, _bitmap_base + end, _page_size);
r = _regions.next();
}
}
};
--- 136,148 ----
while (r != NULL) {
size_t start = r->index() * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
size_t end = (r->index() + 1) * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
assert (end <= _bitmap_size, "end is sane: " SIZE_FORMAT " < " SIZE_FORMAT, end, _bitmap_size);
! if (r->is_committed()) {
! os::pretouch_memory(_bitmap_base + start, _bitmap_base + end, _page_size);
! }
r = _regions.next();
}
}
};
*** 153,167 ****
size_t max_byte_size = MaxHeapSize;
size_t heap_alignment = HeapAlignment;
size_t reg_size_bytes = ShenandoahHeapRegion::region_size_bytes();
- if (AlwaysPreTouch) {
- // Enabled pre-touch means the entire heap is committed right away.
- init_byte_size = max_byte_size;
- }
-
Universe::check_alignment(max_byte_size, reg_size_bytes, "Shenandoah heap");
Universe::check_alignment(init_byte_size, reg_size_bytes, "Shenandoah heap");
_num_regions = ShenandoahHeapRegion::region_count();
--- 157,166 ----
*** 348,381 ****
// For NUMA, it is important to pre-touch the storage under bitmaps with worker threads,
// before initialize() below zeroes it with initializing thread. For any given region,
// we touch the region and the corresponding bitmaps from the same thread.
ShenandoahPushWorkerScope scope(workers(), _max_workers, false);
! size_t pretouch_heap_page_size = heap_page_size;
! size_t pretouch_bitmap_page_size = bitmap_page_size;
#ifdef LINUX
// UseTransparentHugePages would madvise that backing memory can be coalesced into huge
// pages. But, the kernel needs to know that every small page is used, in order to coalesce
// them into huge one. Therefore, we need to pretouch with smaller pages.
if (UseTransparentHugePages) {
! pretouch_heap_page_size = (size_t)os::vm_page_size();
! pretouch_bitmap_page_size = (size_t)os::vm_page_size();
}
#endif
// OS memory managers may want to coalesce back-to-back pages. Make their jobs
// simpler by pre-touching continuous spaces (heap and bitmap) separately.
! log_info(gc, init)("Pretouch bitmap: " SIZE_FORMAT " regions, " SIZE_FORMAT " bytes page",
! _num_regions, pretouch_bitmap_page_size);
! ShenandoahPretouchBitmapTask bcl(bitmap.base(), _bitmap_size, pretouch_bitmap_page_size);
_workers->run_task(&bcl);
! log_info(gc, init)("Pretouch heap: " SIZE_FORMAT " regions, " SIZE_FORMAT " bytes page",
! _num_regions, pretouch_heap_page_size);
! ShenandoahPretouchHeapTask hcl(pretouch_heap_page_size);
_workers->run_task(&hcl);
}
//
// Initialize the rest of GC subsystems
--- 347,376 ----
// For NUMA, it is important to pre-touch the storage under bitmaps with worker threads,
// before initialize() below zeroes it with initializing thread. For any given region,
// we touch the region and the corresponding bitmaps from the same thread.
ShenandoahPushWorkerScope scope(workers(), _max_workers, false);
! _pretouch_heap_page_size = heap_page_size;
! _pretouch_bitmap_page_size = bitmap_page_size;
#ifdef LINUX
// UseTransparentHugePages would madvise that backing memory can be coalesced into huge
// pages. But, the kernel needs to know that every small page is used, in order to coalesce
// them into huge one. Therefore, we need to pretouch with smaller pages.
if (UseTransparentHugePages) {
! _pretouch_heap_page_size = (size_t)os::vm_page_size();
! _pretouch_bitmap_page_size = (size_t)os::vm_page_size();
}
#endif
// OS memory managers may want to coalesce back-to-back pages. Make their jobs
// simpler by pre-touching continuous spaces (heap and bitmap) separately.
! ShenandoahPretouchBitmapTask bcl(bitmap.base(), _bitmap_size, _pretouch_bitmap_page_size);
_workers->run_task(&bcl);
! ShenandoahPretouchHeapTask hcl(_pretouch_heap_page_size);
_workers->run_task(&hcl);
}
//
// Initialize the rest of GC subsystems
*** 2683,2695 ****
// Commit the bitmap slice:
size_t slice = r->index() / _bitmap_regions_per_slice;
size_t off = _bitmap_bytes_per_slice * slice;
size_t len = _bitmap_bytes_per_slice;
! if (!os::commit_memory((char*)_bitmap_region.start() + off, len, false)) {
return false;
}
return true;
}
bool ShenandoahHeap::uncommit_bitmap_slice(ShenandoahHeapRegion *r) {
shenandoah_assert_heaplocked();
--- 2678,2697 ----
// Commit the bitmap slice:
size_t slice = r->index() / _bitmap_regions_per_slice;
size_t off = _bitmap_bytes_per_slice * slice;
size_t len = _bitmap_bytes_per_slice;
! char* start = (char*) _bitmap_region.start() + off;
!
! if (!os::commit_memory(start, len, false)) {
return false;
}
+
+ if (AlwaysPreTouch) {
+ os::pretouch_memory(start, start + len, _pretouch_bitmap_page_size);
+ }
+
return true;
}
bool ShenandoahHeap::uncommit_bitmap_slice(ShenandoahHeapRegion *r) {
shenandoah_assert_heaplocked();
< prev index next >