-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
many magit operations are slowed by forge-get-repository when many forge topics #300
Comments
Edited to reflect that this problem affects many common operations, not just |
|
If I interpret that image correctly (and then some) this means that
What does that confirm and how? (Consider using durations like so): (message "Stuff...done (%.3fs)"
(float-time (time-subtract (current-time) before))) |
(let ((before (float-time)))
(forge-get-repository 'full)
(message "forge-get-repository took %.3fs"
(float-time (time-subtract (current-time) before)))) on a repo with no forge remote configured yields:
On the magit repo, it yields:
Maybe it's not the number of topics but something else; that was an (un)educated guess. |
On the magit repo, it yields 0.02 to 0.04 for me.
Try |
Thanks for the suggestion; unfortunately that toggle makes no difference. Given that most of the time is being spent when |
Don't suppose you've had any ideas for anything else I could investigate on this issue? Forge is still quite painfully slow for me, unfortunately (although I still use it because I love it). |
I suspect you were right when you wrote
So it would be useful if you could try to figure out which of the two it is. |
I just changed (cl-defmethod emacsql ((connection emacsql-connection) sql &rest args)
"Send SQL s-expression to CONNECTION and return the results."
(emacsql-clear connection)
(let ((sql-string (apply #'emacsql-compile connection sql args))
(before (float-time)))
(emacsql-send-message connection sql-string)
(emacsql-wait connection)
(let* ((after (float-time))
(elapsed (- after before)))
(if (> elapsed 0.2)
(message "emacsql: slow query (%fs): %s" elapsed sql-string)))
(emacsql-parse connection))) and immediately saw:
This seems insanely slow for such simple updates. |
Filed at magit/emacsql#81 |
I notice that these slow queries are triggered when entering
Is this correct that it is necessary to run
That seems pretty strange to me, but I'm probably missing something? |
I'm trying this workaround to see if it breaks anything: (remove-hook 'find-file-hook 'forge-bug-reference-setup)
(remove-hook 'magit-mode-hook 'forge-bug-reference-setup) |
Of course if these actions turn out not to be cheap but excessively expensive, then that calculation changes. But we assume that some issue in
It's not necessary but potentially useful. (Some commit messages mention an issue in its summary, and it might be convenient to visit that issue with one key press.)
It probably won't break anything but it almost certainly won't help. Calls to |
@tarsius commented on September 12, 2021 8:17 AM:
I see - thanks for the explanation, and yes, that seems fair. Certainly I would have expected a single
Weirdly, it has helped; at least, (cl-defmethod emacsql ((connection emacsql-connection) sql &rest args)
"Send SQL s-expression to CONNECTION and return the results."
(emacsql-clear connection)
(let ((sql-string (apply #'emacsql-compile connection sql args))
(before (float-time)))
(emacsql-send-message connection sql-string)
(emacsql-wait connection)
(let* ((after (float-time))
(elapsed (- after before)))
(cond ((> elapsed 0.2)
(message "emacsql: slow query (%fs): %s"
elapsed sql-string)
(edebug))
(t
(message "emacsql: fast query (%fs): %s"
elapsed sql-string))))
(emacsql-parse connection))) I added (remove-hook 'git-commit-setup-hook 'forge-bug-reference-setup) too, since creating commits was experiencing the same issue. |
I should mention I also tried running |
I've added optional support for using the sqlite library using a module instead of using a child process. Still highly experimental but it seems faster. To use it you have to:
You can continue using the existing database. |
I've also tried |
I have now releases two new SQLite backends, both maintained at https://github.com/emacscollective/emacsql-sqlite-builtin. They are no longer considered experimental. Please give one of them a try. |
|
I am experiencing a fairly slow magit experience since I added forge. Reading this it doesn't seem like it's an on-going issue (so it could just my network), but just wanted to add that this link goes to a 404. So was this merged into emacsql and is the default? I would like to try to speed up my magit experience back to its original. Sadly, I am not experienced enough in elisp to provide all the statistics that aspiers provided. I can only anecdotally say that the magit experience on a repo is significantly slower since I added forge. @aspiers , if you happen to have any commands I can run to benchmark this, I would be thankful! |
Using this tutorial: https://jakemccrary.com/blog/2020/11/14/speeding-up-magit/ I was able to go from 9s:
To under a second:
I do lose some status data, but I don't think it's really needed. I imagine it will be faster if I removed But idk if I should post this here instead: magit/magit#2982 |
I noticed that many magit and forge operations are slow (e.g. 1 or 2 seconds) when run on a repository which has a lot of forge topics in the emacsql database, such as the magit repo itself. This applies to
magit-status
,magit-commit-create
, and others - in fact just pressing'
to trigger the forge transient is sufficient to trigger it. So I did some profiling via etrace:and loading the resulting
etrace.json
into https://www.speedscope.app/ revealed this:So I added the following debug to
emacsql-wait
:and sure enough, this confirms it:
This is with the latest
master
ofmagit
,forge
,emacsql
, andclosql
(all installed viastraight.el
).I haven't had time to build a reproducible test case yet, so it's possible that this is a local issue with my own
~/.emacs.d/forge-database.sqlite
, but I thought I'd share now anyway in the hope that this might be useful.The text was updated successfully, but these errors were encountered: