You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As per #1376RcString has been renamed to JsString.
This is similar to Rc<str>. But unlike Rc<str> which stores the length on the stack and a pointer to the data The JsString length and data is stored on the heap. (Rc<str> keeps refcount on the heap anyway) and just an non-null pointer is kept on the stack, so its size is the size of a pointer.
Also added JsString::concat(x, y) function, so we don't have to do JsString::new(format!("{}{}", x, y)) which wastes an allocation.
Moved src/value/rcstring.rs=>src/string.rs (like symbol.rs)
Reexport JsString to root level (because its such a common import, like Value)
@HalidOdat just wondering why there should be this strong of a performance improvement, as I'd expect the memory usage to decrease, but due to heap allocations and deallocations being slower than stack shouldn't it have the adverse effect on the runtime?
@HalidOdat just wondering why there should be this strong of a performance improvement, as I'd expect the memory usage to decrease, but due to heap allocations and deallocations being slower than stack shouldn't it have the adverse effect on the runtime?
JsString::concat saves one allocation so that's probably why string concatenation improved Besides that we don't really allocate/deallocate anymore than we did previously. In the benchmarks we can see that the main improvement is in arithmetic operations this is most likely do to the smaller size of Value (from 24 to 16), there are probably other places that have smaller size now, like PropertyKey, Symbol, string property entries, etc.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull Request fixes/closes #1377 .
As per #1376
RcString
has been renamed toJsString
.This is similar to
Rc<str>
. But unlikeRc<str>
which stores the length on the stack and a pointer to the data TheJsString
length and data is stored on the heap. (Rc<str>
keeps refcount on the heap anyway) and just an non-null pointer is kept on the stack, so its size is the size of a pointer.Also added
JsString::concat(x, y)
function, so we don't have to doJsString::new(format!("{}{}", x, y))
which wastes an allocation.Moved
src/value/rcstring.rs
=>src/string.rs
(likesymbol.rs
)Reexport
JsString
to root level (because its such a common import, likeValue
)This should unblock #1373 :)