Commit be2f7d64 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[snapshot] Print allocation stats for memory tests

Since we're not reserving memory anymore, we don't log reserved memory
when profiling serialization. So, instead log the allocation counts used
by OutputStatistics as a pseudo-reserved size.

Bug: v8:10998
Bug: chromium:1075999
Change-Id: I64dc6086b14c0e720ef8d0c1ea99a6f8ccabcf9c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2460808
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70399}
parent c97feb94
......@@ -51,6 +51,14 @@ void Serializer::CountAllocation(Map map, int size, SnapshotSpace space) {
#endif // OBJECT_PRINT
}
int Serializer::TotalAllocationSize() const {
int sum = 0;
for (int space = 0; space < kNumberOfSnapshotSpaces; space++) {
sum += allocation_size_[space];
}
return sum;
}
void Serializer::OutputStatistics(const char* name) {
if (!FLAG_serialization_statistics) return;
......
......@@ -169,6 +169,8 @@ class Serializer : public SerializerDeserializer {
Isolate* isolate() const { return isolate_; }
int TotalAllocationSize() const;
protected:
using PendingObjectReferences = std::vector<int>*;
......
......@@ -348,12 +348,17 @@ v8::StartupData Snapshot::Create(
// TODO(v8:6593): generalize rehashing, and remove this flag.
bool can_be_rehashed = true;
std::vector<int> context_allocation_sizes;
for (int i = 0; i < num_contexts; i++) {
ContextSerializer context_serializer(isolate, flags, &startup_serializer,
embedder_fields_serializers[i]);
context_serializer.Serialize(&contexts->at(i), no_gc);
can_be_rehashed = can_be_rehashed && context_serializer.can_be_rehashed();
context_snapshots.push_back(new SnapshotData(&context_serializer));
if (FLAG_profile_deserialization) {
context_allocation_sizes.push_back(
context_serializer.TotalAllocationSize());
}
}
startup_serializer.SerializeWeakReferencesAndDeferred();
......@@ -364,6 +369,17 @@ v8::StartupData Snapshot::Create(
read_only_serializer.FinalizeSerialization();
can_be_rehashed = can_be_rehashed && read_only_serializer.can_be_rehashed();
if (FLAG_profile_deserialization) {
// These prints should match the regexp in test/memory/Memory.json
PrintF("Deserialization will allocate:\n");
PrintF("%10d bytes per isolate\n",
read_only_serializer.TotalAllocationSize() +
startup_serializer.TotalAllocationSize());
for (int i = 0; i < num_contexts; i++) {
PrintF("%10d bytes per context #%d\n", context_allocation_sizes[i], i);
}
}
SnapshotData read_only_snapshot(&read_only_serializer);
SnapshotData startup_snapshot(&startup_serializer);
v8::StartupData result =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment