-
Notifications
You must be signed in to change notification settings - Fork 71
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
speedup persp-maybe-kill-buffer #171
base: master
Are you sure you want to change the base?
Conversation
Expect that temporary buffers are 'ido-ignore-buffers'. Use 'persp--make-ignore-buffer-rx' to detect them. This is also implemented in other contexts of perspective.el.
Customizable variable to allow a 'persp-maybe-kill-buffer' call to kill 'ido-ignore-buffers' (aka temporary buffers) skipping checks. Temproray buffers usually have a name that starts with a space.
Usually temporary buffers have a name that starts with a space. Set 'ido-ignore-buffers' to a regular expression to detect that in ert's tests.
33b4a2f
to
691eceb
Compare
Benchmark 'persp-maybe-kill-buffer'.
Read perspectives' buffers directly accessing the frame's hash table for performance reasons.
Do not remove buffers from perspectives via 'with-perspective' macro. It takes a heavy toll when switching perspective. Access the frame's hash table directly instead. This improves performance but doesn't update a windows configuration, like properly removing a buffer from the current perspective does.
Due to 'persp-maybe-kill-buffer' amendments, force update the 'current-buffer' to the current window's buffer after calling 'kill-buffer'.
Implement a dirty flag to let a perspective forget buffers which are found in windows, but do not belong to the perspective. A buffer removed from a perspective by manipulating the frame's hash table, requires the perspective's dirty flag to be set. This is required since 'persp-maybe-kill-buffer' no longer updates a perspective's windows configuration. When a removed buffer is still part of a windows configuration, a perspective will get back removed buffers when re-activated.
Unset feature flag by default, due to nex3#168 possibly beeing fixed.
Set feature flag by default, due to nex3#168 possibly beeing fixed.
691eceb
to
0813f6a
Compare
Thanks! I'll need some time to review all that. |
Sure, take your time. Thanks, let me know. |
@mehw: I like your approach, and as always, I'm impressed by the thoroughness of your tests. Unfortunately, I'm running into trouble with some basics. In particular, commit 4b0ef93 introduces a problem: It's reproducible on my system just by doing this:
Substitute paths as needed. I'm... not sure what's going on here:
|
@gcv: It's quite odd... thanks for bringing that out. I'm looking into it... I didn't manage to sort out the problem yet. |
@gcv: I'm sorry for not posting for so long... I finally have time to resume working on the PR... Thank you so much for waiting patiently in these strange times... ;) |
All good! Looking forward to reviewing your work. |
@mehw: Do you think you'll have time to look into this? If not, I've been using |
@gcv: Yes, sorry, a lot has happened... I was optimistic that I could get back on track uninterrupted, but sometimes problems await us just around the corner... I look into it. I have to rebase the PR and make the point about the error you reported:
I was able to address the problem, but still it's not clear to me the real source of it. |
@gcv: Hi, I rebased the patch set on master, all tests passed. About the error triggered by the below command,
|
Okay, sounds good, let me know when you want me to take another look. Thanks for working on this. |
Hi @gcv, I've done some progress, and things are more clear. I need your help to decide about the appropriate behavior. ProblemThe value of the DebuggingRight now, I'm refining the ert tests about how and when the ExplanationIn vanilla (aka Bottom line
What do you suggest? Thank you a lot ;) |
Does the |
Yes, it does. |
Lines 969 to 973 in 4e38680
I'm not sure how current-buffer and window visibility is affected in the case of |
I just renamed it and turned it on by default. Let's get more people on that code path. Looking forward to your code changes. |
Thank you for waiting so patiently. Often I fear that the lack of new commits of mine is mistaken as lack of commitment. |
No rush and no worries! We're all volunteers here, and this is about Emacs. It's all in good fun. |
@gcv: This PR possibly fixes #168 (decreased processing speed during a
persp-maybe-kill-buffer
duty cycle). It may relate also to #164 and #167.DISCLAIMER:
basic-persp-killing-buffers-benchmark
may crash Emacs. If it does, try to repeat the test.In brief:
persp-maybe-kill-buffer
removes buffers manipulating the frame's hash table directly, and sets a perspective's dirty flag to update the windows configuration when the perspective ispersp-activate
re-activated.The first commit of this PR is just a starting point I needed, a remainder from where to begin, a plain changelog update.
Switching perspective repeatedly is time consuming. In reference to
perps-maybe-kill-buffer
, the speed improvements gained with this PR are due to removing buffers manipulating the frame's hash table directly, rather than switching to a perspective first.The major difference between switching-perspective-then-removing-buffer and remove-buffer-from-hash-table is that the former also updates a perspective's windows configuration.
Not updating a windows configuration means that once a perspective is switched to via
persp-activate
(aka re-activated), removed buffers still present in the windows configuration will be pulled back into the perspective... Unless a dirty flag is used...Once set, a perspective's dirty flag allows to update a windows configuration only when it's time to do it, i.e. during a
persp-activate
cycle, buffers not belonging to the perspective (pulled back in by the windows configuration) will be forgotten by the perspective automatically.persp-maybe-kill-buffer: different approaches, from last PR's commit to old behavior
Each section below has a descriptive header of the
persp-maybe-kill-buffer
behavior. Then, pseudo code and benchmark results will follow (a buffer is killed to collect the timings ofkill-buffer
, thepersp-maybe-kill-buffer
duty cycle is executed only when enabled by thepersp-feature-flag-prevent-killing-last-buffer-in-perspective
flag).Benchmark creating
20 perspectives * (51 regular buffers + 51 temporary buffers)
. All buffers are shared between perspectives, including"*dummy*"
and" *foo*"
. Before killig a buffer, the buffer ispersp-set-buffer
to the current perspective, to remove it from other perspectives (allowing it to be killed for sure, but still be part of a perspective). The sequence is:persp-maybe-kill-buffer
;Performance flag enabled/disabled:
persp-feature-flag-directly-kill-ido-ignore-buffers
Enables/Disables
persp-maybe-kill-buffer
:persp-feature-flag-prevent-killing-last-buffer-in-perspective
verify buffer accessing the frame's hash table, remove from hash table and set dirty flag
verify buffer accessing the frame's hash table, then switch perspectives and remove buffer
verify buffer switching perspectives, then switch perspectives and remove buffer