Hello V8 team, thanks for making V8 engine which could run JavaScript super fast.
Recently, I want to improve the performance of deserialization for Cocos Creator game engine.
Cocos Creator uses V8 for its default JavaScript engine and benefited from V8's high performance. There're many classes implemented in JS and some implemented in C++. And there will be more and more JS code moved to C++ side.
I thought about deserializing game assets directly in C++ rather than in JS to get better performance since I think C++ code should be faster.
Therefore, I wrote a testcase to test whether we could get benefited from C++ code. But unfortunately, I got a really bad result saying that create JS object and setting properties in C++ by V8 API is really slower than doing that in JS. It's about 50 times slower, in another word, JS execution is really fast.
I debugged a little bit and found that the most heavy cost is in v8::Object::Set and v8::String::NewFromUtf8.
Part of JS test code:
const testArr = new Array<MySerializationTestClass>(this.loopCount);test['stringValue1'] = 'hello 1';
The logic of CPP test code is the same as which in the above JS test code. The difference is that we use v8::Object::Set API.
### JIT Enabled
Cpp code is 55 times slower than JS code.
### JIT Disabled
Cpp code is 16 times slower than JS code.
### Xcode Profile
`v8::Maybe<bool> ret = _obj.handle(__isolate)->Set(__isolate->GetCurrentContext(), nameValue.ToLocalChecked(), value);` and `v8::String::NewFromUtf8` are the main hotspots.
### What I guess
I guess running JS code directly could make use of the optimization by V8 Bytecode and JIT by TurboFan. But invoking V8 C++ API will not get the optimization.
Could you point me out that whether my guess is correct or not? Also, is there a better V8 API for setting property? Thanks.
--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/721fa65a-e310-4315-9166-e6beae89ce47n%40googlegroups.com.
Google Germany GmbH
Erika-Mann-Straße 33
80636 München
Geschäftsführer: Paul Manicle, Liana Sebastian.
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.
This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.
--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/efc01cf2-8383-4034-abff-5a0d2cc54bd4n%40googlegroups.com.