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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 14246029: Remove heap snapshot size limit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // as small as possible. 183 // as small as possible.
184 namespace { // Avoid littering the global namespace. 184 namespace { // Avoid littering the global namespace.
185 185
186 template <size_t ptr_size> struct SnapshotSizeConstants; 186 template <size_t ptr_size> struct SnapshotSizeConstants;
187 187
188 template <> struct SnapshotSizeConstants<4> { 188 template <> struct SnapshotSizeConstants<4> {
189 static const int kExpectedHeapGraphEdgeSize = 12; 189 static const int kExpectedHeapGraphEdgeSize = 12;
190 static const int kExpectedHeapEntrySize = 24; 190 static const int kExpectedHeapEntrySize = 24;
191 static const int kExpectedHeapSnapshotsCollectionSize = 100; 191 static const int kExpectedHeapSnapshotsCollectionSize = 100;
192 static const int kExpectedHeapSnapshotSize = 132; 192 static const int kExpectedHeapSnapshotSize = 132;
193 static const size_t kMaxSerializableSnapshotRawSize = 256 * MB;
194 }; 193 };
195 194
196 template <> struct SnapshotSizeConstants<8> { 195 template <> struct SnapshotSizeConstants<8> {
197 static const int kExpectedHeapGraphEdgeSize = 24; 196 static const int kExpectedHeapGraphEdgeSize = 24;
198 static const int kExpectedHeapEntrySize = 32; 197 static const int kExpectedHeapEntrySize = 32;
199 static const int kExpectedHeapSnapshotsCollectionSize = 152; 198 static const int kExpectedHeapSnapshotsCollectionSize = 152;
200 static const int kExpectedHeapSnapshotSize = 160; 199 static const int kExpectedHeapSnapshotSize = 160;
201 static const uint64_t kMaxSerializableSnapshotRawSize =
202 static_cast<uint64_t>(6000) * MB;
203 }; 200 };
204 201
205 } // namespace 202 } // namespace
206 203
207 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection, 204 HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
208 const char* title, 205 const char* title,
209 unsigned uid) 206 unsigned uid)
210 : collection_(collection), 207 : collection_(collection),
211 title_(title), 208 title_(title),
212 uid_(uid), 209 uid_(uid),
(...skipping 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 2374
2378 2375
2379 // type, name|index, to_node. 2376 // type, name|index, to_node.
2380 const int HeapSnapshotJSONSerializer::kEdgeFieldsCount = 3; 2377 const int HeapSnapshotJSONSerializer::kEdgeFieldsCount = 3;
2381 // type, name, id, self_size, children_index. 2378 // type, name, id, self_size, children_index.
2382 const int HeapSnapshotJSONSerializer::kNodeFieldsCount = 5; 2379 const int HeapSnapshotJSONSerializer::kNodeFieldsCount = 5;
2383 2380
2384 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { 2381 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) {
2385 ASSERT(writer_ == NULL); 2382 ASSERT(writer_ == NULL);
2386 writer_ = new OutputStreamWriter(stream); 2383 writer_ = new OutputStreamWriter(stream);
2387
2388 HeapSnapshot* original_snapshot = NULL;
2389 if (snapshot_->RawSnapshotSize() >=
2390 SnapshotSizeConstants<kPointerSize>::kMaxSerializableSnapshotRawSize) {
2391 // The snapshot is too big. Serialize a fake snapshot.
2392 original_snapshot = snapshot_;
2393 snapshot_ = CreateFakeSnapshot();
2394 }
2395
2396 SerializeImpl(); 2384 SerializeImpl();
2397
2398 delete writer_; 2385 delete writer_;
2399 writer_ = NULL; 2386 writer_ = NULL;
2400
2401 if (original_snapshot != NULL) {
2402 delete snapshot_;
2403 snapshot_ = original_snapshot;
2404 }
2405 } 2387 }
2406 2388
2407 2389
2408 HeapSnapshot* HeapSnapshotJSONSerializer::CreateFakeSnapshot() {
2409 HeapSnapshot* result = new HeapSnapshot(snapshot_->collection(),
2410 snapshot_->title(),
2411 snapshot_->uid());
2412 result->AddRootEntry();
2413 const char* text = snapshot_->collection()->names()->GetFormatted(
2414 "The snapshot is too big. "
2415 "Maximum snapshot size is %" V8_PTR_PREFIX "u MB. "
2416 "Actual snapshot size is %" V8_PTR_PREFIX "u MB.",
2417 SnapshotSizeConstants<kPointerSize>::kMaxSerializableSnapshotRawSize / MB,
2418 (snapshot_->RawSnapshotSize() + MB - 1) / MB);
2419 HeapEntry* message = result->AddEntry(HeapEntry::kString, text, 0, 4);
2420 result->root()->SetIndexedReference(HeapGraphEdge::kElement, 1, message);
2421 result->FillChildren();
2422 return result;
2423 }
2424
2425
2426 void HeapSnapshotJSONSerializer::SerializeImpl() { 2390 void HeapSnapshotJSONSerializer::SerializeImpl() {
2427 ASSERT(0 == snapshot_->root()->index()); 2391 ASSERT(0 == snapshot_->root()->index());
2428 writer_->AddCharacter('{'); 2392 writer_->AddCharacter('{');
2429 writer_->AddString("\"snapshot\":{"); 2393 writer_->AddString("\"snapshot\":{");
2430 SerializeSnapshot(); 2394 SerializeSnapshot();
2431 if (writer_->aborted()) return; 2395 if (writer_->aborted()) return;
2432 writer_->AddString("},\n"); 2396 writer_->AddString("},\n");
2433 writer_->AddString("\"nodes\":["); 2397 writer_->AddString("\"nodes\":[");
2434 SerializeNodes(); 2398 SerializeNodes();
2435 if (writer_->aborted()) return; 2399 if (writer_->aborted()) return;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 2658
2695 2659
2696 void HeapSnapshotJSONSerializer::SortHashMap( 2660 void HeapSnapshotJSONSerializer::SortHashMap(
2697 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2661 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2698 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2662 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2699 sorted_entries->Add(p); 2663 sorted_entries->Add(p);
2700 sorted_entries->Sort(SortUsingEntryValue); 2664 sorted_entries->Sort(SortUsingEntryValue);
2701 } 2665 }
2702 2666
2703 } } // namespace v8::internal 2667 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698