Repository navigation
Conversation
|
Hey, this is cool. I have a few questions:
|
|
I am looking over nnethercote, Rust performance book and have some thoughts As @devyn say the biggest culprit Record is currently 72 bytes, and it seem to be because the two Additional thought, should the indexes stored in a Vec be allocated with an arena allocator to reuse allocations and deallocations? |
|
#12252 I boxed the records and the new largest is |
|
Thanks for taking on this massive endeavour @kubouch ! My two cents to the comments from @devyn and @FilipAndersson245 I think we should keep the priority on this PR to get the correctness (and existing error reporting features if possible) right and directly compare what saving the 8 bytes (which is the required alignment of On top of perf proving out the IDs may make it easier if we swap out the parser or introduce compression/GC of the source cache. After that we can compare different options for optimal memory layout. |
Do you plan to replace the current parser entirely? I'm curious about the "array-based" approach. Why do we need a new parser? Why does it need to use SpanId instead of Span? |
If every Span is replaced by SpanId, then it should shrink the whole Value by 8 bytes, though it depends on alignment and padding as well. I'm kind of half-thinking that after the span replacement, the Values could perhaps be stored in an array-like fashion as in the parser and then you could do all sorts of memory optimizations.
Not sure what you mean by deriving spans from spans. You mean stuff like
I'm thinking errors could stay as-is for now. When creating an error you'd need to look up the span with SpanId from the state. We'll see how it goes once I progress with it :-D. The plugin-engine chatter from looking up spans from IDs sounds bad, but plugins shouldn't really need it that much, apart from creating errors, but perhaps that could be also abstracted somehow via the engine interface so that we don't need to go back and forth with the spans. @FilipAndersson245 @yizhepku |
|
It's a pity that we don't have a way to test span values automatically. Actually I'm not sure for one question: can it saves memory usage? After this pr, spans are saved in |
My 2cent would be that it would be fever larger allocations that are more likely to be on the hot path. About the second point im not sure, seeds like a resonable problem, maybe we would have to add a gc or simular in the mid term? |
Sorry, I didn't see your reply until now. There are methods on |
|
@devyn I've seen the |
Description
Starting a big refactor that will change Expressions and Values (and possibly other related types) to use Span IDs pointing at an array of spans instead of storing the spans manually.
This should save 8 bytes on every Expression/Value etc. Given how much overhead in Nushell is caused by memory (de)allocation, there is a high chance of positive performance impact.
The main motivation, though, is preparing for the new (WIP!) parser, which uses the array-based approach throughout. After this refactor, it should be much easier to adapt the evaluator to the output of the new parser.
The plan is to finish up this PR before the next release and merge in the calm period after the release to avoid excessive merge conflicts piling up during normal operation.
TODO:
format pattern.get_span()to.span()TODO span_idTODO SPANdetect columnsstill worksUser-Facing Changes
Hopefully none, except possibly performance improvements.
Temporarily disabled
format patternbecause it was trying to do evalTests + Formatting
After Submitting