|
11 | 11 | [cider.nrepl.middleware :as mw]
|
12 | 12 | [cider.nrepl.middleware.util.cljs :as cljs]
|
13 | 13 | [cider.nrepl.print-method] ;; we load this namespace, so it's directly available to clients
|
| 14 | + [compliment.core :as compliment] |
14 | 15 | [haystack.analyzer :as analyzer]
|
15 | 16 | [nrepl.middleware :refer [set-descriptor!]]
|
16 | 17 | [nrepl.middleware.caught :refer [wrap-caught]]
|
|
51 | 52 | (catch Exception _))
|
52 | 53 | @analyzer/spec-abbrev
|
53 | 54 |
|
54 |
| -(defn warmup-orchard-caches! |
55 |
| - "Warms up `orchard.java/cache`, drastically improving the completion and info UX performance for first hits. |
56 |
| - (This was our behavior for many years, |
57 |
| - then had to be disabled for test suite reasons in Orchard 0.15.0 to 0.17.0 / cider-nrepl 0.38.0 to 0.41.0, and now it's restored again) |
58 |
| - Note that this can only be done cider-nrepl side, unlike before when it was done in Orchard itself." |
| 55 | +(defn warmup-caches! |
| 56 | + "Warm up some of the dependency caches to improve UX performance for first hits. |
| 57 | + The warmups should be non-invasive (avoid unpredictable side-effects like e.g. |
| 58 | + loading classes). Currently only warms up Compliment, others are TBD." |
59 | 59 | []
|
60 |
| - ;; Cache classes that are `:import`ed throughout the project. The class list |
61 |
| - ;; is obtained through `ns` form analysis, so that we don't depend on whether |
62 |
| - ;; the namespaces have been loaded yet: |
63 |
| - (doseq [ns-form (vals (orchard.namespace/project-ns-forms)) |
64 |
| - class-sym (orchard.namespace/ns-form-imports ns-form) |
65 |
| - :when (try |
66 |
| - (Class/forName (str class-sym) |
67 |
| - false ;; Don't initialize this class, avoiding side-effects (including static class initializers; with the exception of static fields with an initial value) |
68 |
| - (.getContextClassLoader (Thread/currentThread))) |
69 |
| - (catch Throwable _))] |
70 |
| - (orchard.java/class-info class-sym)) |
71 |
| - ;; 3.- Leave an indicator that can help up assess the cache size in a future: |
72 |
| - (-> orchard.java/cache .keySet .size)) |
73 |
| - |
74 |
| -(def initializer |
75 |
| - (future |
76 |
| - (warmup-orchard-caches!))) |
| 60 | + (try |
| 61 | + ;; This call removes the delay from the next `.prefix` completion. |
| 62 | + (compliment/completions ".sub") |
| 63 | + (catch Throwable t |
| 64 | + (println "Error during" `warmup-caches! ":" (str t))))) |
| 65 | + |
| 66 | +(defonce ^:private warmup-once |
| 67 | + (.start (Thread. ^Runnable warmup-caches!))) |
77 | 68 |
|
78 | 69 | ;;; Functionality for deferred middleware loading
|
79 | 70 | ;;
|
|
0 commit comments