Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: runtime/vm/heap.cc

Issue 511963007: Pretenure some strings into bump-allocated block (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
===================================================================
--- runtime/vm/heap.cc (revision 39687)
+++ runtime/vm/heap.cc (working copy)
@@ -33,11 +33,18 @@
DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation.");
DEFINE_FLAG(int, new_gen_ext_limit, 64,
"maximum total external size (MB) in new gen before triggering GC");
+DEFINE_FLAG(int, pretenure_threshold, 98,
+ "Trigger pretenuring when this many percent are promoted.");
+DEFINE_FLAG(int, pretenure_interval, 10,
+ "Back off pretenuring after this many cycles.");
Heap::Heap(Isolate* isolate,
intptr_t max_new_gen_semi_words,
intptr_t max_old_gen_words)
- : isolate_(isolate), read_only_(false), gc_in_progress_(false) {
+ : isolate_(isolate),
+ read_only_(false),
+ gc_in_progress_(false),
+ pretenure_policy_(0) {
for (int sel = 0;
sel < kNumWeakSelectors;
sel++) {
@@ -138,6 +145,15 @@
return 0;
}
+
+uword Heap::AllocatePretenured(intptr_t size) {
+ ASSERT(isolate()->no_gc_scope_depth() == 0);
+ uword addr = old_space_->TryAllocateDataBump(size, PageSpace::kControlGrowth);
+ if (addr != 0) return addr;
+ return AllocateOld(size, HeapPage::kData);
+}
+
+
void Heap::AllocateExternal(intptr_t size, Space space) {
ASSERT(isolate()->no_gc_scope_depth() == 0);
if (space == kNew) {
@@ -269,6 +285,7 @@
UpdateClassHeapStatsBeforeGC(kNew);
new_space_->Scavenge(invoke_api_callbacks);
isolate()->class_table()->UpdatePromoted();
+ UpdatePretenurePolicy();
RecordAfterGC();
PrintStats();
if (old_space_->NeedsGarbageCollection()) {
@@ -321,6 +338,7 @@
UpdateClassHeapStatsBeforeGC(kNew);
new_space_->Scavenge(kInvokeApiCallbacks);
isolate()->class_table()->UpdatePromoted();
+ UpdatePretenurePolicy();
RecordAfterGC();
PrintStats();
}
@@ -335,6 +353,29 @@
}
+bool Heap::ShouldPretenure(intptr_t class_id) const {
+ if (class_id == kOneByteStringCid) {
+ return pretenure_policy_ > 0;
+ } else {
+ return false;
+ }
+}
+
+
+void Heap::UpdatePretenurePolicy() {
+ ClassHeapStats* stats =
+ isolate_->class_table()->StatsWithUpdatedSize(kOneByteStringCid);
+ int allocated = stats->pre_gc.new_count;
+ int promo_percent = (allocated == 0) ? 0 :
+ (100 * stats->promoted_count) / allocated;
+ if (promo_percent >= FLAG_pretenure_threshold) {
+ pretenure_policy_ += FLAG_pretenure_interval;
+ } else {
+ pretenure_policy_ = Utils::Maximum(0, pretenure_policy_ - 1);
+ }
+}
+
+
void Heap::SetGrowthControlState(bool state) {
old_space_->SetGrowthControlState(state);
}
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698