-
Notifications
You must be signed in to change notification settings - Fork 921
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
Performance issues with object property lookup #245
Comments
Which part of the code is measured? The array creation or the array element access? The code fragment seems to suggest a timing of 83ms for just a single access |
yes, a timing of a single access a[1], you can see the code for my time consumption statistics is printed before and after a[1]. |
I'm not sure what you mean, but I tried running it with quickjs-ng and the results were pretty similar, even though it used an inline cache. |
FWIW, I tested it and got the same results. Even when using the v8 command line with no JIT. |
This looks like a gc issue or possibly a paging issue. I get a slow timing of 29ms the first time and 0ms after that. Edit: indeed a gc issue, see below |
Yeah, I noticed that too. Doesn't seem relevant. |
I modified the test:
The timings are: The problem is unrelated to the object access
|
While not portable, I guess testing with |
|
I nailed it! Creating a new object ultimately calls This test is pathological as it constructs a huge object in one long loop without constructing any other object and allocating and reallocating a lot of memory so the next object creation triggers a gc for sure. We could improve the gc speed by keeping a flag in each object indicating if any of the properties are (or have been) objects references, hence accelerating the scan for arrays and objects with just scalar property values (undefined, null, boolean, numbers, strings...). I am not sure how this would impact the overall performance of the interpreter (just a marginal cost when setting property values, that might be implemented without branching). It should reduce the gc overhead significantly, thereby reducing the lag it can cause in large applications. |
The cost time between QuickJS and V8 (Node) when running the above code.
quickjs: 83 ms
v8: 1 ms
Object property queries under QuickJS still take a relatively long time, I would like to understand the reason for this performance gap, and whether there are any optimization strategies. Additionally, when I changed the object to an array, I was able to save about half of the time
The text was updated successfully, but these errors were encountered: