branch: elpa/racket-mode
commit 577af47246e1ce9fe5c17847eefe0e9513ca7049
Author: Greg Hendershott <[email protected]>
Commit: Greg Hendershott <[email protected]>
Lazy-require more modules to speed initial startup
Lazy-require hash-lang-bridge.rkt, package.rkt, and scribble.rkt.
On my machine, this causes racket--cmd-ready-p to go from reporting
over 8 seconds to under 5 seconds.
Of course, this only defers load time -- gets to "ready for any first
command" faster. When the back end is started /because of/ a command
needing one of those modules, that /total/ load time won't be
faster (and in fact could be slightly slower). Even so, I think this
is a good approach to get the back end up quickly, and not presume the
set of features actually utilized by any given user.
---
racket/command-server.rkt | 15 +++++++++------
racket/hash-lang-bridge.rkt | 3 +--
racket/hash-lang-channel.rkt | 14 ++++++++++++++
racket/package-channel.rkt | 11 +++++++++++
racket/package.rkt | 7 ++-----
racket/scribble.rkt | 3 +--
6 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/racket/command-server.rkt b/racket/command-server.rkt
index d974e328415..7df1dff66c2 100644
--- a/racket/command-server.rkt
+++ b/racket/command-server.rkt
@@ -10,15 +10,12 @@
"debug.rkt"
"elisp.rkt"
(only-in "instrument.rkt" get-uncovered get-profile)
- "hash-lang-bridge.rkt"
+ "hash-lang-channel.rkt"
"logger.rkt"
- "package.rkt"
+ "package-channel.rkt"
"repl.rkt"
"repl-output.rkt"
"repl-session.rkt"
- (only-in "scribble.rkt"
- bluebox-command
- doc-search)
"util.rkt")
(lazy-require
@@ -29,7 +26,13 @@
["commands/macro.rkt" (macro-stepper macro-stepper/next)]
["commands/requires.rkt" (requires/tidy requires/trim requires/base)]
["commands/module-names.rkt" (module-names)]
- ["find.rkt" (find-definition find-definition/drracket-jump)])
+ ["find.rkt" (find-definition find-definition/drracket-jump)]
+ ["hash-lang-bridge.rkt" (hash-lang)]
+ ["package-.rkt" (package-list
+ package-details
+ package-op
+ catalog-package-doc-link)]
+ ["scribble.rkt" (bluebox-command doc-search)])
(provide command-server-loop)
diff --git a/racket/hash-lang-bridge.rkt b/racket/hash-lang-bridge.rkt
index a1dc15a30cb..06a77206ee9 100644
--- a/racket/hash-lang-bridge.rkt
+++ b/racket/hash-lang-bridge.rkt
@@ -8,6 +8,7 @@
racket/match
racket/runtime-path
"elisp.rkt"
+ "hash-lang-channel.rkt"
"lang-info.rkt"
"util.rkt")
@@ -90,8 +91,6 @@
[`(submit-predicate ,id ,str ,eos?)
(submit-predicate id str eos?)]))
-(define hash-lang-notify-channel (make-async-channel))
-
(define ht (make-hash)) ;id => hash-lang%
(define (get-object id)
(hash-ref ht id
diff --git a/racket/hash-lang-channel.rkt b/racket/hash-lang-channel.rkt
new file mode 100644
index 00000000000..24f199ec36e
--- /dev/null
+++ b/racket/hash-lang-channel.rkt
@@ -0,0 +1,14 @@
+;; Copyright (c) 2025 by Greg Hendershott.
+;; SPDX-License-Identifier: GPL-3.0-or-later
+
+#lang racket/base
+
+;; Facilitate lazy-require of hash-lang-bridge.rkt by
+;; command-server.rkt, by moving this to its own, non-lazy module.
+
+(require racket/async-channel)
+
+(provide hash-lang-notify-channel)
+
+(define hash-lang-notify-channel (make-async-channel))
+
diff --git a/racket/package-channel.rkt b/racket/package-channel.rkt
new file mode 100644
index 00000000000..56d976f5d61
--- /dev/null
+++ b/racket/package-channel.rkt
@@ -0,0 +1,11 @@
+;; Copyright (c) 2025 by Greg Hendershott.
+;; SPDX-License-Identifier: GPL-3.0-or-later
+
+#lang racket/base
+
+;; Facilitate lazy-require of package.rkt by command-server.rkt, by
+;; moving this to its own, non-lazy module.
+
+(provide package-notify-channel)
+
+(define package-notify-channel (make-channel))
diff --git a/racket/package.rkt b/racket/package.rkt
index 190ec1d8473..8accfd1bfb9 100644
--- a/racket/package.rkt
+++ b/racket/package.rkt
@@ -4,7 +4,6 @@
(only-in racket/hash hash-union!)
racket/match
racket/path
- racket/promise
(only-in racket/string string-join)
(except-in pkg/lib
pkg-desc)
@@ -28,6 +27,7 @@
pkg/name
(only-in setup/getinfo get-info/full)
net/url
+ "package-channel.rkt"
(only-in "scribble.rkt"
module-doc-path
refresh-doc-index!))
@@ -35,8 +35,7 @@
(provide package-list
package-details
package-op
- catalog-package-doc-link
- package-notify-channel)
+ catalog-package-doc-link)
(define (package-list)
(define installed (installed-packages))
@@ -277,8 +276,6 @@
;;; package operations
-(define package-notify-channel (make-channel))
-
(define sema (make-semaphore 1))
(define (package-op verb name)
diff --git a/racket/scribble.rkt b/racket/scribble.rkt
index ce2bb2f4db6..c12905422d8 100644
--- a/racket/scribble.rkt
+++ b/racket/scribble.rkt
@@ -17,7 +17,6 @@
scribble/xref
scribble/tag
setup/main-doc
- version/utils
"define-fallbacks.rkt"
"lib-pkg.rkt"
"util.rkt"
@@ -282,7 +281,7 @@
[(module-path-index-desc? desc)
(define pkg-sort (lib-pkg-sort (string->symbol term)))
(values "module" "" "" pkg-sort 0)]
- [else
+ [else
(define pkg-sort (lib-pkg-sort #f))
(values "documentation" (doc-from) "" pkg-sort 0)]))
(list term sort-order what from fams pkg-sort path anchor))