On Mon, May 13, 2019 at 8:49 PM Joel Scarfone <joelrscarf...@gmail.com> wrote: > > Hi All! I have a very simple program as follows that just creates an isolate, > then sleeps: > > #include <libplatform/libplatform.h> > #include <v8-platform.h> > #include <v8.h> > > #include <stdio.h> > #include <unistd.h> > > using v8::Isolate; > > int main() { > > std::unique_ptr<v8::Platform> platform = > v8::platform::NewDefaultPlatform(); > v8::V8::InitializePlatform(platform.get()); > v8::V8::Initialize(); > > v8::Isolate::CreateParams create_params; > create_params.array_buffer_allocator = > v8::ArrayBuffer::Allocator::NewDefaultAllocator(); > Isolate* isolate = v8::Isolate::New(create_params); > > > printf("Sleeping...\n"); > usleep(1000 * 1000 * 100); > printf("Done\n"); > return 0; > } > > When i run this program, i can then check the number of threads the process > has created with ps -T -p <process_id>, and i see that on my 8 core machine, > v8 creates 7 extra threads all named "V8 WorkerThread", and on my 16 core > machine i get 8 instances of this "V8 WorkerThread" created. > > I am looking to understand what determines the number of extra threads v8 > spawns and what the purpose of these threads are. Thanks in advance! > > Joel
V8 spawns those threads for off-thread concurrent (re)compilation and garbage collection. You can pass a `thread_pool_size` argument to NewDefaultPlatform() to configure its size (0 == default size == max(1, min(8, number_of_cpus-1))) or plug in your Platform implementation. You can also pass `--predictable` or `--single_threaded` to V8::SetFlagsFromString() to disable the thread pool but you'll probably take a performance hit when you do. Hope that helps! -- -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAHQurc9gEGU%2BZdxhp9c3peOU1saNvBef5vwKOmJPddwngCmEEQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.