Skip to content

Conversation

@thecoolwinter
Copy link
Contributor

Description

  • Added a new debug mode for visualizing line fragment invalidation.
  • Adjusted the layout pass to avoid typesetting lines that don't need layout.
    • Made a distinction between 'forced layout' via setNeedsLayout and 'continued' layout where a line previously scanned in the layout pass was updated.
    • Due to that, I was able to check if a line fragment actually needed typesetting or just potentially needed to have it's position adjusted.
    • Added a new method to update a line's view's positions during layout.
  • Removed the unnecessary lineRange variable on the LineFragment class.
  • Adjusted the use of documentRange on the LineFragment class. It's now updated during layout, simplifying various methods.

Related Issues

  • N/A

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Before:

Screen.Recording.2025-07-21.at.4.21.43.PM.mov

After:

Screen.Recording.2025-07-21.at.4.17.29.PM.mov

@thecoolwinter thecoolwinter merged commit e7f1580 into CodeEditApp:main Jul 23, 2025
2 checks passed
@thecoolwinter thecoolwinter deleted the layout-invalidation-performance branch July 23, 2025 17:21
@thecoolwinter
Copy link
Contributor Author

Posting this a little after the fact, but here's a profile from a regular editing session before this change. Each keystroke the profiler marks as a hang, and over the duration of the editing the minimap and textview take up a combined 36% of CPU time

image

After these changes, theres very very few detected hangs* and text layout now only takes up 5% of CPU time that's an 87% reduction

image
  • (all under 60ms and related to tree-sitter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant