-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: JsrtGet/Set property from JsValueRef and more. #3790
Comments
I ran into similar issues with concat strings that are used in property accesses. For this, I added a It seems like this should fit your needs? Caveats: |
@MikeHolman I'm already looking into it. Thanks for pointing this out! |
Noticed the
https://github.com/Microsoft/ChakraCore/blob/master/lib/Backend/Lower.cpp#L15254 This looks like the only direct use of |
I'm also planing to wipe |
See |
AcmeAIR LTO gain (3%) New JSRT property interface that API user can use without going through convert-to-property-id process. See chakra-core#3790 for details. Also added a TODO note; ``` TODO: Can we make PropertyString && LiteralStringWithPropertyStringPtr share the string buffer? ``` Once this PR is merged, there will be an additional PR on node-chakracore end to benefit this new interface.
…perty Merge pull request #3875 from obastemur:desert_cerodon AcmeAIR LTO gain (3%) New JSRT property interface that API user can use without going through convert-to-property-id process. See #3790 for details. Also added a note; ``` TODO: Can we make PropertyString && LiteralStringWithPropertyStringPtr share the string buffer? ``` Once this PR is merged, there will be an additional PR on node-chakracore end to benefit this new interface.
Implemented. |
Using Jsrt, there is no direct way to use a
JavascriptString
object for property identifier.expensive loop
: Get the string from JsValueRef -> Convert to Utf16 -> Lookup / convert to JsPropertyRef... -> etc.. and finally Get OR Set the property!So.. If we had an interface that accepts JsValueRef, we wouldn't have to do all these stuff.
This alone should change the things for node-chakracore. (AcmeAir perf wise.)
However, I would like to take it one step further and implement a string type that is very similar to Js::PropertyString with some differences.
Js::JsrtString
(or however we are going to call)Structure-wise, apart from being a regular
JavascriptString
... it will be holding a pointer toPropertyRecord
+ another pointer for extension / Jsrt call caching purposes. (Memory wise, it will cost +16 bytes on top of standard JavascriptString)PropertyRecord
ptr by default will benullptr
... It will be filled, once thisJsrtString
object is used for any property related purposes. Additional usages will be saving fromstring TO propertyId
hashing / lookup... (name it!) And... from GC point.. Yes, as long as this string object is alive, PropertyRecord will be alive too.JsrtCreateString...
will create this newJsrtString
by default. (In case the string length is bigger than 128 char, it will create the good oldJavascriptString
instead.`** Q/A **
Why not using
Js::PropertyString
?That would cost +32 bytes. It also expects every string variable to be property string... and will ask for PropertyRecord from the beginning... etc. ( <- some cache related stuff )
Expected gain?
Somewhere between 2% to 10% AcmeAIR LTO gain.
2% or 10% ? How did you calculate this?
Average AcmeAIR benchmark request forces the above mentioned "expensive loop" aprox. 50+ times.. In other words, ~80 times each milliseconds. (considering 1730 requests/second rate on the machine I do the benchmark)...
1 ms ==> 2.7Ghz => 2.7 e6 ticks (aprox CPU hertz) / 80times == > So... per each
33750
cpu ticks, we do one of these heavy loops. One loop costs somewhere between 2% to 10% of the available cpu ticks... Hence, this work may end-up giving 2% gain or something around 10%... or less...How much change needed on Chakrashim end?
Not much.
Chakracore?
Not much.
I will start hacking soon on this.
Opinions? Objections?
The text was updated successfully, but these errors were encountered: