sony/v8eval

Passing Flags Down To V8

paetling opened this issue · 3 comments

Hello,
I really love the repo. Once everything is installed it has been very helpful. We are looking to use v8eval to build a very parallel go server that sends requests to javascript v8 to process and return information.

Everything in v8eval makes this pretty easy. On NewV8() a new V8 isolate is created and returned to the user. This is perfect for running v8 in many different threads concurrently. We want our server to be able to do some data intensive work and have many different isolates running at once. To do this we really need more than the 64 bit minimum memory, 1.4 GBs (https://bugs.chromium.org/p/v8/issues/detail?id=847).

The way node handles this, and the way that seems best moving forward, is to pass a list of command line arguments through to V8's SetFlagsFromCommandLine function. I think it would be a good idea to pass a list of args to Initialize() and have that list passed on to setFlags function. This not only would enable more memory, but also manual garbage collection and more fine tuning of the v8 engine.

I was planning on forking and trying to do this myself, but was wondering if you had thoughts about the problem at all or had any suggestions on how best or where best to set these flags?

Thanks and I will submit a PR when I am done.

Thank you for your feedback and pull request. I agree that v8eval should handle V8 flags. I will consider the best way to set flags and keep compatibility. After experimental implementation on another branch, I will let you know how it goes.

I have added v8eval.SetFlags that wraps V8's SetFlagsFromString simply. SetFlagsFromString has a simple interface and can handle multiple flags. So I think it's better to expose it in the same way.

I have also set the finalizer for V8 instances so that the Go GC can free unreachable V8 instances.

See https://github.com/sony/v8eval/commits/develop

I have released v8eval 0.2.6 that includes v8eval.SetFlags. If you have any more problems, please feel free to let me know.