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

Side by Side Diff: runtime/vm/megamorphic_cache_table.cc

Issue 2007233002: Add --dump-megamorphic-stats. Lower megamorphic cache load factor to 50%. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/megamorphic_cache_table.h" 5 #include "vm/megamorphic_cache_table.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/stub_code.h" 10 #include "vm/stub_code.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 85
86 void MegamorphicCacheTable::PrintSizes(Isolate* isolate) { 86 void MegamorphicCacheTable::PrintSizes(Isolate* isolate) {
87 StackZone zone(Thread::Current()); 87 StackZone zone(Thread::Current());
88 intptr_t size = 0; 88 intptr_t size = 0;
89 MegamorphicCache& cache = MegamorphicCache::Handle(); 89 MegamorphicCache& cache = MegamorphicCache::Handle();
90 Array& buckets = Array::Handle(); 90 Array& buckets = Array::Handle();
91 const GrowableObjectArray& table = GrowableObjectArray::Handle( 91 const GrowableObjectArray& table = GrowableObjectArray::Handle(
92 isolate->object_store()->megamorphic_cache_table()); 92 isolate->object_store()->megamorphic_cache_table());
93 if (table.IsNull()) return; 93 if (table.IsNull()) return;
94 intptr_t max_size = 0;
94 for (intptr_t i = 0; i < table.Length(); i++) { 95 for (intptr_t i = 0; i < table.Length(); i++) {
95 cache ^= table.At(i); 96 cache ^= table.At(i);
96 buckets = cache.buckets(); 97 buckets = cache.buckets();
97 size += MegamorphicCache::InstanceSize(); 98 size += MegamorphicCache::InstanceSize();
98 size += Array::InstanceSize(buckets.Length()); 99 size += Array::InstanceSize(buckets.Length());
100 if (buckets.Length() > max_size) {
101 max_size = buckets.Length();
102 }
99 } 103 }
100 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", 104 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n",
101 table.Length(), size / 1024); 105 table.Length(), size / 1024);
106
107 intptr_t* probe_counts = new intptr_t[max_size];
108 intptr_t entry_count = 0;
109 intptr_t max_probe_count = 0;
110 for (intptr_t i = 0; i < max_size; i++) {
111 probe_counts[i] = 0;
112 }
113 for (intptr_t i = 0; i < table.Length(); i++) {
114 cache ^= table.At(i);
115 buckets = cache.buckets();
116 intptr_t mask = cache.mask();
117 intptr_t capacity = mask + 1;
118 for (intptr_t j = 0; j < capacity; j++) {
119 intptr_t class_id =
120 Smi::Value(Smi::RawCast(cache.GetClassId(buckets, j)));
121 if (class_id != kIllegalCid) {
122 intptr_t probe_count = 0;
123 intptr_t probe_index =
124 (class_id * MegamorphicCache::kSpreadFactor) & mask;
125 intptr_t probe_cid;
126 while (true) {
127 probe_count++;
128 probe_cid =
129 Smi::Value(Smi::RawCast(cache.GetClassId(buckets, probe_index)));
130 if (probe_cid == class_id) {
131 break;
132 }
133 probe_index = (probe_index + 1) & mask;
134 }
135 probe_counts[probe_count]++;
136 if (probe_count > max_probe_count) {
137 max_probe_count = probe_count;
138 }
139 entry_count++;
140 }
141 }
142 }
143 intptr_t cumulative_entries = 0;
144 for (intptr_t i = 0; i <= max_probe_count; i++) {
Ivan Posva 2016/05/25 17:27:53 0->1 as 0 probes have a low likelihood at succeedi
145 cumulative_entries += probe_counts[i];
146 OS::Print("Megamorphic probe %" Pd ": %" Pd " (%lf)\n",
147 i, probe_counts[i],
148 static_cast<double>(cumulative_entries) /
149 static_cast<double>(entry_count));
150 }
151 delete probe_counts;
102 } 152 }
103 153
104 } // namespace dart 154 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698