-
Notifications
You must be signed in to change notification settings - Fork 91
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
Optimize rendering by bulk-adding text highlights and reducing unnecessary work #341
Conversation
I'm trying out using bulk editor changes for removing highlighters too, if it works I'll add one more commit. |
There is indeed a bunch of global state which needs to be removed. In specific scenarios, this is known to cause race conditions (cf. #187, #132, #142, #147, #338), which I have tried (unsuccessfully) to debug on several occasions, as you might have noticed with the |
I was thinking about that. Would you be okay with bumping the line width limit from 80 to 140? If I were to rewrite a bunch of things I find 80 is too restrictive and leads to high vertical density, because if lines can be longer it's easier to vertically space them out. |
The default line width is set here, although it was never strictly enforced: Line 7 in b1d69bf
In order to preserve the Git blame history, I would just change the locations you feel are necessary to semantically modify. |
It wouldn't be a good idea to pull in the refactor as-is because I basically moved everything (which obviously breaks external usages) and haven't re-implemented all the features and subtleties of how AceJump works to work without all the global state. I think the best option after I finish the rewrite would be to write down a list of all the bugfixes and tweaks I made, let you pick what you want again, and port those to the current codebase just so the bugs and annoyances are addressed first. I'm not sure if the refactor will be in a pullable state, but at minimum I can think of some things that could be integrated pretty easily:
I also very recently realized (related to this PR) that switching the bulk editing mode takes some time, so I ended up only turning on Anyway, my work-in-progress refactor branch is at https://github.com/chylex/AceJump/tree/humongous-refactor if you want to take an early look and perhaps integrate some things immediately, but you would have to be careful to only take parts that haven't moved/removed old behaviors, which might be a challenge. The only significant global state is now in |
Looks great! The only things we need to be careful about modifying are the methods annotated with One idea I've meant to implement for a while is a trie-based index. Not sure if this is what you had in mind with the This would be extremely fast and solve our latency problems once and for all, however it would need to listen for editor changes in realtime and be updated incrementally each time the editor text was modified. Keeping the index in sync with the editor would require some ingenuity, but would allow instantaneous tagging and meet the constraints of the the tag assignment problem.
Great! This looks like just what we needed.
Better to remove non-essential behaviors and focus on the default case. The regex-based search and tag placement rules, for example are notoriously buggy. I would just tear out everything you think is not essential and focus on code quality. We can figure out how to reimplement them later once we have a stateless implementation. |
Decided to open #348 to continue the discussion, so it doesn't get easily lost in an unrelated PR. |
It's not trivial to test how much faster this is, so I recorded a video and counted frames between the loudest point of the key press waveform and the when search highlights (not markers) started appearing on the screen. Excluding the first key press because it takes a bit longer, the averages are:
One thing I did was
As far as I can tell this only adds a small caret highlight, but repeatedly calling
Selector.nearestVisibleMatches()
made for a sizeable chunk in the profiler, so I commented it out for now. If you'd rather have the results cached somewhere, let me know how you'd want to implement it, there appears to be a lot of global state scattered around so I'm not sure.