-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Faster REPL - don't load extra middleware on first sync eval request #2078
Conversation
From #2081:
It depends how long would it take to release 0.16. I would like to see #2069 in 0.16 and that change with associated features/fixes might take quite some months. If we can pull it in within a couple of months then this change can also go in 0.16, if not then it might be better included now. As noted in 721440b, there is one side effect of dynamic loading of middlware - it can occur concurrently. But Clojure seems to have trouble loading namespaces in parallel. I haven't investigated this thoroughly but I run into issues when debug middleware was requested before Fixing this on cider's side is easy, just implement a kind of deffered chain to load cider's middleware. But then, some other packages (nrepl-refactor?) might load same namespaces in parallel. One partial solution is to run |
Is this due to dependencies between namespaces? Needs a topological sort? |
No. It's just that if two actions simultaneously try to load same namespace, something goes wrong and one of them is not loaded correctly. |
Can you put up a minimal repo that reproduces this problem? Seems like a Clojure level issue, not |
Yes, it's a Clojure level issue. If I had a minimal rep. example I would have had already reported it on JIRA. |
Things like these are generally my concern - don't like introducing potentially breaking changes in a bugfix release.
There's never a precise roadmap for releases. Generally I cut them when I feel we've added something important enough to warrant a release. |
cider-repl.el
Outdated
"Set the REPL BUFFER's initial namespace (by altering `cider-buffer-ns'). | ||
This is \"user\" by default but can be overridden in apps like lein (:init-ns)." | ||
(defun cider-repl-require-repl-utils-and-set-ns (buffer) | ||
"Require standard REPL util functions and set the REPL BUFFER NS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NS -> ns (it's not a param).
cider-repl.el
Outdated
This is \"user\" by default but can be overridden in apps like lein (:init-ns)." | ||
(defun cider-repl-require-repl-utils-and-set-ns (buffer) | ||
"Require standard REPL util functions and set the REPL BUFFER NS. | ||
Namespace is \"user\" by default but can be overridden in apps like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default, but
cider-repl.el
Outdated
(defun cider-repl-require-repl-utils-and-set-ns (buffer) | ||
"Require standard REPL util functions and set the REPL BUFFER NS. | ||
Namespace is \"user\" by default but can be overridden in apps like | ||
lein (:init-ns). Booth of these operations need to be done as a sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
booth -> both
cider-repl.el
Outdated
"Require standard REPL util functions and set the REPL BUFFER NS. | ||
Namespace is \"user\" by default but can be overridden in apps like | ||
lein (:init-ns). Booth of these operations need to be done as a sync | ||
request at the beginning of the session. Bundling them for efficiency." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one space missing here before the final sentence.
them -> them together
(when cider-repl-display-in-current-window | ||
(add-to-list 'same-window-buffer-names (buffer-name buffer))) | ||
(pcase cider-repl-pop-to-buffer-on-connect | ||
(`display-only (display-buffer buffer)) | ||
((pred identity) (pop-to-buffer buffer))) | ||
(cider-repl-require-repl-utils-and-set-ns buffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move those down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The REPL shows a bit earlier (.5-1 sec for me). Also, the repl is always shown, even when errors occur with those subsequent requests.
cider.el
Outdated
(cider--subscribe-repl-to-server-out) | ||
(when cider-auto-mode | ||
(cider-enable-on-existing-clojure-buffers)) | ||
;; Middleware on cider-nrepl side is loaded dynamically on first | ||
;; usage. Loading middleware concurrently can lead to confusing issues | ||
;; (likely a clojure bug). Debug middleware is heavy, so enable it at the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall you verified this is a bug, so I think you should mention it here. The next sentence doesn't sound very reassuring. 😃
I guess you can also add to this PR a changelog entry, as users are going to be quite excited about the speedup. |
@vspinu ping :-) |
Sorry for being slow on this. My kid was just born a couple of weeks ago, so my bandwidth is 1/10th of what it was before :) Will try to fix all my PRs by Saturday. |
Thanks and congratulations! 🎉 🎂 |
5dbdf2f
to
4b4aa08
Compare
- Sending :inhibit-cider-middleware condition on first request - Combining require-repl-utils and set-initial-ns into one sync request for efficiency
@bbatsov, I have addressed your comments in all of my PRs (also the one on cider-nrepl side). Added all change-log entries here to avoid conflicts. |
👍 |
This saves a couple of extra seconds and brings cider repl startup time to barebones empty-project
lein repl
of 4s for me.Send :inhibit-cider-middleware condition on first request. Relies on a feature added in Dynamically load middleware cider-nrepl#438.
Combine
require-repl-utils
andset-initial-ns
into one sync request for efficiency. Note thatrequire-repl-utils
needs to be a sync request. It could happen that the following init-debuger request would occur before it has finished, resulting in "reader/reader not found error".