On Thu, Feb 15, 2018 at 9:28 PM, Chris Dumoulin <crdum...@gmail.com> wrote:
> I'm interested in minimizing v8 memory usage, and I recently saw this blog > post on Lazy Deserialization: https://v8project.blogspot.ca/2018/02/ > lazy-deserialization.html > > I've built and run samples/hello-world.cc against static libraries built > from v6.3 and v6.5, and measured the memory usage using Valgrind's Massif > tool. > I expect to see a reduction in memory usage with v6.5 (due to the lazy > deserialization), but I don't. Is there something I need to do in the code > to enable the lazy deserialization? > Are you sure you're using a snapshot build? If so, lazy deserialization should be enabled by default. What architecture / OS? Locally (Linux x64), I see these numbers: $ out/release/v8_hello_world --no-lazy-deserialization --no-lazy-handler-deserialization --trace-gc Hello, World! name, size, size of objects new_space, 23408, 23408 old_space, 820176, 437832 code_space, 1039904, 1039904 map_space, 525904, 40400 large_object_space, 0, 0 $ out/release/v8_hello_world --trace-gc Hello, World! name, size, size of objects new_space, 23408, 23408 old_space, 820176, 437832 code_space, 898208, 396448 map_space, 525904, 40400 large_object_space, 0, 0 Note the difference in code_space. The 'size' column shows the total size of the space, 'size of objects' shows the portion that is actually used/allocated. >From a quick look, Massif also didn't show a difference for me. By the way, since you're looking into memory reductions, isolate-independent builtins (doc <http://goo.gl/Z2HUiM>) might also be of interest. Here's the patch to reproduce my numbers above: diff --git a/samples/hello-world.cc b/samples/hello-world.cc index ab6f0dd8bf..d9257d79e9 100644 --- a/samples/hello-world.cc +++ b/samples/hello-world.cc @@ -16,6 +16,7 @@ int main(int argc, char* argv[]) { std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform(); v8::V8::InitializePlatform(platform.get()); v8::V8::Initialize(); + v8::V8::SetFlagsFromCommandLine(&argc, argv, true); // Create a new Isolate and make it the current one. v8::Isolate::CreateParams create_params; diff --git a/src/isolate.cc b/src/isolate.cc index 30f67e3233..b85bf18179 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -2629,6 +2629,13 @@ void Isolate::Deinit() { DumpAndResetStats(); + printf("name, size, size of objects\n"); + for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) { + Space* s = heap_.space(i); + printf("%s, %zu, %zu\n", heap_.GetSpaceName(i), s->Size(), + s->SizeOfObjects()); + } + if (FLAG_print_deopt_stress) { PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); } -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.