-
Notifications
You must be signed in to change notification settings - Fork 102
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
Suspected poor performance from rustic-syntax-propertize #107
Comments
Thanks for the bug report! I don't have the time to take a look at it at the moment. Any help is appreciated. |
I'm not sure how much more I can provide, given my limited experience in these areas, but I'm happy help in whatever way I can. |
I'm afraid we have to look at the code. Maybe the function has to be rewritten. I didn't write it so I don't know how it works. |
Maybe we should try this |
Yep, fixed that finally yesterday. Why are there two code bases again? |
Because we want a lightweight package and a package that comes with all features. I know this sucks, but making rustic depend on rust-mode is a lot of work... |
I took a look at those changes; its seems like rustic.el and rust-mode.el have diverged quite a bit, and I'm not comfortable with elisp to make a useful patch, I don't think. I tried just applying a patch straight out of rust-mode, but it fails. I'm sorry I'm not more useful here. |
It should patch up, but it would have to done manually. The change in rust-mode is mostly in a single function (rustic-in-macro) which is largely the same form as the old rust-in-macro. |
The `rustic-syntax-propertize` function in rustic (set as `syntax-propertize-function` in emacs) had a performance regression (reported in brotzeit/rustic#107) that caused emacs to effectively lock up every time the viewport changed. This was fixed upstream in rust-mode by @phillord in rust-lang/rust-mode@bfe4056, and ported to rustic by @brotzeit in brotzeit/rustic#108. I've confirmed that this version of rustic seems to resolve the issue.
brotzeit/rustic@32a962a -> brotzeit/rustic@52b632d The `rustic-syntax-propertize` function in rustic (set as `syntax-propertize-function` in emacs) had a performance regression (reported in brotzeit/rustic#107) that caused emacs to effectively lock up every time the viewport changed. This was fixed upstream in rust-mode by @phillord in rust-lang/rust-mode@bfe4056, and ported to rustic by @brotzeit in brotzeit/rustic#108. Closes #3144 Co-authored-by: Jack Brown <jack@brownjohnf.com>
It still doesn't seem to be solved completely. |
@brownjohnf can you do me a favor and try it with rust-mode ? Would be good to know if rust-mode also still has this issue. |
@brownjohnf another round of testing please ;) |
You got it! I can do that some time today. |
Re testing with rust-mode, I could probably get something together, but as a doom emacs user, I'm not sure exactly how that would work, or how accurate a test result it would be in that context. Seems like with these changes in #109, I'll just test those and hopefully that'll sort things out. |
Probably I would port this commit as well. For me, now, |
Unfortunately, it's still not looking great :-(. I'm attaching a screenshot from the latest test. I took a look at the @phillord In your comment above, are you saying that |
@brownjohnf I am saying that the fix to |
@brownjohnf I wasn't able to reproduce a laggy behaviour. Can you give me some context so I can try to reproduce it ? |
Sorry about the delay here. I basically hit it any time that I'm editing larger files. Probably once I'm over ~500 lines, but it's hard to say for certain. Once the effect is noticeable, it basically freezes the editor any time the viewport changes. So things like jumping around in the file can take ~3 seconds or more. Once you're actually inputting text, sometimes it's laggy and sometimes not. Haven't really found a pattern here. Maybe depends on whether the input pushes text off the edge of the viewport? I should also say that I'm using evil-mode, and that I'm using it in doom emacs. However, I had no issues whatsoever prior to the changes that caused the poor performance, so I don't think it's caused by doom/evil. |
It would be really nice if you(or anybody else with this issue) could find the time to test it with vanilla emacs and rustic only. And if it persists it would be good to also try it with rust-mode. Just load rustic with |
I was also observing serious lag --- and the top line of the profile @brownjohnf listed here #107 (comment) provided the key clue. I had adaptive-wrap-prefix-mode enabled --- turning it off seems to eliminate the lag. |
@jbms Thanks for the info. @brownjohnf can you confirm this ? |
Hmmm. |
Sorry about my long silence here... life stuff and all. I've actually recently switched from rls to rust-analyzer and fully enabled everything in rustic (I'd previously disabled |
If there are still problems with this, please reopen this issue. @phillord @brownjohnf thanks for your help. |
Hello, I'm facing the exact issue.
I can also confirm that disabling |
The issue now belongs to rust-mode. Please comment in the linked issue instead. |
@darwin67 added a note to the readme |
Thanks! |
I hadn't realised that you had unforked rustic and rust-mode. Good job and thanks for the work! |
Hello! I apologize if I'm confused or misguided here, but I believe that the
rustic-syntax-propertize
function is locking up emacs frequently when editing any rust source file of non-trivial size. It seems that with anything larger than about 100 lines emacs becomes pretty much unusable.This suddenly started happening a few weeks ago, and at first I thought it was my workstation, but then had the same thing happen after switching to another workstation, but only after upgrading my doom emacs installation. Unfortunately, I don't recall whether I updated rust/rls at the same time. I'm not proficient with emacs lisp, so from the little of the source I've looked at, it's unclear how much this function relies on rls for any functionality.
I tracked down this function as the culprit by running the profiler in emacs; as you can see in the screenshot, it's consuming ~75% of CPU and 55% memory during my sample run; that's pretty typical over the 2 machines and several samples I've run. Specifically,
rustic-ordinary-lt-gt-p
seems to be the problem function.As I said before, this very much outside my area of expertise, so I might be completely wrong, but I'm hitting dead-ends on trying to find any other issue in other projects that explain it, so I thought I'd bring it up here. I am running nightly rust, but I've been updating frequently since hitting this issue and the problem persists, so if that's the cause it's something more than a whoops commit.
Setting
syntax-propertize-function
tonil
appears to completely resolve the problem, but then you don't get formatting while editing. That's been my workaround today since tracking this down.The text was updated successfully, but these errors were encountered: