-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
[Merged by Bors] - Improve JsString
performance
#2042
Conversation
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #2042 +/- ##
==========================================
+ Coverage 43.90% 44.14% +0.23%
==========================================
Files 212 212
Lines 18734 18841 +107
==========================================
+ Hits 8226 8318 +92
- Misses 10508 10523 +15
Continue to review full report at Codecov.
|
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Simplify it, now |
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The principle used here is a tagged pointer right? There should be an explicit mention of that in the comments, so that everyone knows what is being done.
I'm not too familiar with the platform requirements for tagged pointers. I assume this would fail on 16 bit platforms? Are there any other requirements that should be noted?
I think if we implement this, we would have to at least mention these requirements, at best prevent boa from compiling if any of the requirements are not met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of this PR very much! However, I think it would be good to check with miri if the pointer provenance of our Inner
pointer is preserved between casts.
It works on 16 bit machine, because we only use the first bit. So far there is no side effect of introducing this technique, since |
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
A larger This goes back to my previous question, should |
I think this is a performance property that we would have to adjust based on real-word benchmarks. In theory a longer Maybe there is some research already done in other engines that we could base a decision upon, but I think for now this is totally fine.
I think inserting into |
As expected, running
Meaning the provenance of the pointer is not preserved. The fix is pretty easy, we just need to use |
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
BenchmarksClick to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments about the implementation. I also tinkered a bit with the documentation to make it a bit more clearer.
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! There are still some nitpicks I have, but it's looking pretty good nonetheless :)
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Let's wait until the ones who left comments approve 😄
Signed-off-by: YXL <chenxin.lan.76@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! :)
bors r+ |
It changes the following: - The current `JsString` implementation has a lot of duplicate heap allocations. For static strings, `JsString` only needs to store the index of `CONSTANTS_ARRAY`. ~~I let `JsString` can store pointer to heap or static area. The two are distinguished by the first bit. (This implementation is rough, maybe we should put flag into `Inner`, like [arcstr](https://github.com/thomcc/arcstr/blob/70ba2fac19d3efe8d2e0231daaf74f9987c04b8a/src/arc_str.rs#L751-L757))~~ - I also added more string constants, which are always used.
Pull request successfully merged into main. Build succeeded: |
JsString
performanceJsString
performance
It changes the following: - The current `JsString` implementation has a lot of duplicate heap allocations. For static strings, `JsString` only needs to store the index of `CONSTANTS_ARRAY`. ~~I let `JsString` can store pointer to heap or static area. The two are distinguished by the first bit. (This implementation is rough, maybe we should put flag into `Inner`, like [arcstr](https://github.com/thomcc/arcstr/blob/70ba2fac19d3efe8d2e0231daaf74f9987c04b8a/src/arc_str.rs#L751-L757))~~ - I also added more string constants, which are always used.
It changes the following:
JsString
implementation has a lot of duplicate heap allocations. For static strings,JsString
only needs to store the index ofCONSTANTS_ARRAY
.I letJsString
can store pointer to heap or static area. The two are distinguished by the first bit. (This implementation is rough, maybe we should put flag intoInner
, like arcstr)