-
Notifications
You must be signed in to change notification settings - Fork 282
perf(text-buffer-view): cache measureForDimensions results #475
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
Conversation
…ions Cache measureForDimensions by (buf, epoch, width, wrap_mode) so Yoga remeasure calls avoid repeated rope walks even when dirty flags are cleared or buffers switch. Reuse the measure arena with retain_capacity to avoid mmap churn during streaming. For width==0 or wrap_mode==.none, compute max width by scanning marker line widths to handle multi-seg lines.
Relaxed perf test threshold (3x -> 5x) to handle CI runner variability. The 5x threshold still catches O(n^2) regressions effectively.
|
See this PR for something similar. Notice I had to measure with the max height otherwise there were some visual bugs, like in opencode the absolutely positioned autocomplete was appearing out of place, did you already test if that works in opencode with this branch? |
|
@remorses are these issues you had reproducible with a test maybe? |
|
@remorses I can't reproduce an issue with the autocomplete position on this branch. |
|
Taking this over #456 for having it in native, plus the arena fix. |
|
Thanks @kommander, for adding the typescript integration tests and merging. I haven't really gotten around looking into that part of the code much yet so it wasn't on my mind that it was a possibility. I originally started looking into this based on the anomalyco/opencode#6172 issue. I felt this PR was about as minimal as you can go with mitigation the issue, without rewriting things to consider only the viewport or something like that. |
|
Cool! What is the performance increase after this change? |
|
~50x performance improvement for static content, according to the benchmark from ~90ms to ~1.5ms. |
--------- Co-authored-by: Sebastian Herrlinger <hasta84@gmail.com>
Yoga calls measureForDimensions repeatedly during layout. This adds caching
keyed by (buffer, epoch, width, wrap_mode) to avoid repeated rope walks.
I can split up the arena-reuse if you prefer that in another PR.