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

Side by Side Diff: src/profile-generator.cc

Issue 7832003: A temporary workaround for huge heap snapshots problem. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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/profile-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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 void HeapSnapshot::Delete() { 1188 void HeapSnapshot::Delete() {
1189 collection_->RemoveSnapshot(this); 1189 collection_->RemoveSnapshot(this);
1190 delete this; 1190 delete this;
1191 } 1191 }
1192 1192
1193 1193
1194 void HeapSnapshot::AllocateEntries(int entries_count, 1194 void HeapSnapshot::AllocateEntries(int entries_count,
1195 int children_count, 1195 int children_count,
1196 int retainers_count) { 1196 int retainers_count) {
1197 ASSERT(raw_entries_ == NULL); 1197 ASSERT(raw_entries_ == NULL);
1198 raw_entries_ = NewArray<char>(
1199 HeapEntry::EntriesSize(entries_count, children_count, retainers_count));
1200 #ifdef DEBUG
1201 raw_entries_size_ = 1198 raw_entries_size_ =
1202 HeapEntry::EntriesSize(entries_count, children_count, retainers_count); 1199 HeapEntry::EntriesSize(entries_count, children_count, retainers_count);
1203 #endif 1200 raw_entries_ = NewArray<char>(raw_entries_size_);
1204 } 1201 }
1205 1202
1206 1203
1207 static void HeapEntryClearPaint(HeapEntry** entry_ptr) { 1204 static void HeapEntryClearPaint(HeapEntry** entry_ptr) {
1208 (*entry_ptr)->clear_paint(); 1205 (*entry_ptr)->clear_paint();
1209 } 1206 }
1210 1207
1211 void HeapSnapshot::ClearPaint() { 1208 void HeapSnapshot::ClearPaint() {
1212 entries_.Iterate(HeapEntryClearPaint); 1209 entries_.Iterate(HeapEntryClearPaint);
1213 } 1210 }
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2977 v8::OutputStream::kAbort) aborted_ = true; 2974 v8::OutputStream::kAbort) aborted_ = true;
2978 } 2975 }
2979 2976
2980 v8::OutputStream* stream_; 2977 v8::OutputStream* stream_;
2981 int chunk_size_; 2978 int chunk_size_;
2982 ScopedVector<char> chunk_; 2979 ScopedVector<char> chunk_;
2983 int chunk_pos_; 2980 int chunk_pos_;
2984 bool aborted_; 2981 bool aborted_;
2985 }; 2982 };
2986 2983
2984 const int HeapSnapshotJSONSerializer::kMaxSerializableSnapshotRawSize =
2985 384 * 1024;
William Hesse 2011/09/05 07:31:00 We have constants KB, MB, and GB defined in global
mnaganov (inactive) 2011/09/05 07:33:10 Thanks! I forgot about that, will fix before landi
2986
2987 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { 2987 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) {
2988 ASSERT(writer_ == NULL); 2988 ASSERT(writer_ == NULL);
2989 writer_ = new OutputStreamWriter(stream); 2989 writer_ = new OutputStreamWriter(stream);
2990 2990
2991 HeapSnapshot* original_snapshot = NULL;
2992 if (snapshot_->raw_entries_size() >= kMaxSerializableSnapshotRawSize) {
2993 // The snapshot is too big. Serialize a fake snapshot.
2994 original_snapshot = snapshot_;
2995 snapshot_ = CreateFakeSnapshot();
2996 }
2991 // Since nodes graph is cyclic, we need the first pass to enumerate 2997 // Since nodes graph is cyclic, we need the first pass to enumerate
2992 // them. Strings can be serialized in one pass. 2998 // them. Strings can be serialized in one pass.
2993 EnumerateNodes(); 2999 EnumerateNodes();
2994 SerializeImpl(); 3000 SerializeImpl();
2995 3001
2996 delete writer_; 3002 delete writer_;
2997 writer_ = NULL; 3003 writer_ = NULL;
3004
3005 if (original_snapshot != NULL) {
3006 delete snapshot_;
3007 snapshot_ = original_snapshot;
3008 }
2998 } 3009 }
2999 3010
3000 3011
3012 HeapSnapshot* HeapSnapshotJSONSerializer::CreateFakeSnapshot() {
3013 HeapSnapshot* result = new HeapSnapshot(snapshot_->collection(),
3014 HeapSnapshot::kFull,
3015 snapshot_->title(),
3016 snapshot_->uid());
3017 result->AllocateEntries(2, 1, 0);
3018 HeapEntry* root = result->AddRootEntry(1);
3019 HeapEntry* message = result->AddEntry(
3020 HeapEntry::kString, "The snapshot is too big", 0, 4, 0, 0);
3021 root->SetUnidirElementReference(0, 1, message);
3022 result->SetDominatorsToSelf();
3023 return result;
3024 }
3025
3026
3001 void HeapSnapshotJSONSerializer::SerializeImpl() { 3027 void HeapSnapshotJSONSerializer::SerializeImpl() {
3002 writer_->AddCharacter('{'); 3028 writer_->AddCharacter('{');
3003 writer_->AddString("\"snapshot\":{"); 3029 writer_->AddString("\"snapshot\":{");
3004 SerializeSnapshot(); 3030 SerializeSnapshot();
3005 if (writer_->aborted()) return; 3031 if (writer_->aborted()) return;
3006 writer_->AddString("},\n"); 3032 writer_->AddString("},\n");
3007 writer_->AddString("\"nodes\":["); 3033 writer_->AddString("\"nodes\":[");
3008 SerializeNodes(); 3034 SerializeNodes();
3009 if (writer_->aborted()) return; 3035 if (writer_->aborted()) return;
3010 writer_->AddString("],\n"); 3036 writer_->AddString("],\n");
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 3294
3269 3295
3270 void HeapSnapshotJSONSerializer::SortHashMap( 3296 void HeapSnapshotJSONSerializer::SortHashMap(
3271 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3297 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3272 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3298 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3273 sorted_entries->Add(p); 3299 sorted_entries->Add(p);
3274 sorted_entries->Sort(SortUsingEntryValue); 3300 sorted_entries->Sort(SortUsingEntryValue);
3275 } 3301 }
3276 3302
3277 } } // namespace v8::internal 3303 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698