-
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
Function invocation slow when stored by run-time calculated key #1153
Comments
Could anybody suggest me any any workarounds that may improve speed of sample code? |
Hi @iskiselev , Thanks for reporting this issue. I looked at stable.html and observed that it was calling a method invoked via [] operator and the method name starts with 0. We try to convert constructs of the form A workaround for this would be to set your property as Looking at generated.html now. Btw, I tried the other variants too, and Edge seems to be on par with Chrome in prototype.html. |
@rajatd, thank you for your advice. I've updated my test case with moving |
@iskiselev, I was looking into Generated case with @LouisLaf. Like stable, it too invokes a method via [] operator but this time, it has a concat inside [ ]. Unfortunately, we don't generate optimal code for looking up property names that come from string operations (such as concat in this case). We discussed what would be required to optimize such cases in the JIT backend. Basically, the JIT will have to detect string literals and generate code assuming that the [ ] operator was actually a dot operator. Also, could you provide an overview of what is it that you're trying to achieve through function invocation using runtime calculated key? It'll be helpful for us to better understand the issue and maybe we could come up with a workaround. |
@rajatd, really Generated case tried to avoid using of concat inside [], as I already found that it is slow.
I do concatenation of string to form key in string before invoking function constructor. When we translate .Net sources, we may have virtual functions, besides function with same name may have several overload. In run-time we assign id for each .Net type representation, and form real name for methods.
Suppose in run-time we assigned next ID: Then, we will define on Base prototype next methods:
And on Derived prototype:
For invocation, we encode proper method signature into special object - something like:
There, $asm01 and $jsilcore - are objects that contains our .Net types from corresponding assembly. |
When I changed generated function, to call function through dot-expression, it start working OK in Chakra (see generateForChakra.html). So, if we are talking about my previous sample:
It feels as lack in Chakra function optimization, that it was unable to found effective constant expression and make dot-optimization itself. It steal works slower than other browsers, and it steal slower than "Stable" version. |
@iskiselev the reason for remaining perf difference between Edge and other browsers on generatedForChakra is most likely that we don't inline calls in functions created via Function("..."). For the string concat case, we have ideas of how to make it more performant but our resources are invested in higher priority perf work items at this point. |
Not a bug as semantics are correct, but performance could be improved. |
If it's still an actionable issue, do we want to close this? We could move it to the Backlog milestone instead. |
I'm working on sq/JSIL#993 and try to find a way for fast invocation of method stored in object by run-time calculated key. I've write some tests to found a way for finding proper JS form, and looks like Edge works much slower than other browsers. Please see my results in table sq/JSIL#993 (comment).
What is really bad, it works very slow (30-50 times) for last too options (Stable/Generated), which are the best for other browsers, and really only way for implementing dynamic method invocation.
Here are my test cases.
The text was updated successfully, but these errors were encountered: