You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See retrogradeorbit/bootleg#65. When pods have lots of client side code and many namespace all of this code is evaluated during load-pod, which is potentially a waste of time, since not every script is going to use all of the evaluated code.
Maybe we could defer loading of pod namespace code to the require of that namespace. This would work for sci since we have control over require. For Clojure it would be slightly more complicated. We'd probably have to patch load to take control over loading pod namespaces:
$ time ./bb /tmp/bootleg.clj
loading pod
"Elapsed time: 34.016951 msecs"
loading utils
"Elapsed time: 1.771767 msecs"
loading xml
"Elapsed time: 0.507533 msecs"
loading enlive-html
"Elapsed time: 34.126741 msecs"
loading enlive
"Elapsed time: 30.818078 msecs"
"Elapsed time: 16.301291 msecs"
"<p>foo</p>"
./bb /tmp/bootleg.clj 0.08s user 0.04s system 78% cpu 0.153 total
The net win compared to loading all the namespaces during startup doesn't seem to be so big here since this example still requires the namespaces that are macro heavy:
$ time /usr/local/bin/bb /tmp/bootleg.clj
loading pod
"Elapsed time: 115.301959 msecs"
loading utils
"Elapsed time: 0.020333 msecs"
loading xml
"Elapsed time: 0.013172 msecs"
loading enlive-html
"Elapsed time: 0.011473 msecs"
loading enlive
"Elapsed time: 0.012528 msecs"
"Elapsed time: 15.561942 msecs"
"<p>foo</p>"
/usr/local/bin/bb /tmp/bootleg.clj 0.10s user 0.03s system 78% cpu 0.165 total
Custom require for pods: (pods/require 'retrogradeorbit.bootleg.enlive :as enlive)
Pods only declare their namespaces in describe, but not the associated vars. With pods/require (syntactically the same as require) pod namespaces get loaded.
This would be easier to implement for both sci and Clojure. We could still support the old way of loading pods. Syntactically it would be less appealing and would require configuration for clj-kondo.
The text was updated successfully, but these errors were encountered:
I think loading namespace code definitions on require is a great mitigation as quite often different namespaces can be for different use cases. For example I have lots of bootleg code that uses enlive but not hickory, and other that use hickory and not enlive. So makes sense to only load that which is being used.
See retrogradeorbit/bootleg#65. When pods have lots of client side code and many namespace all of this code is evaluated during
load-pod
, which is potentially a waste of time, since not every script is going to use all of the evaluated code.Maybe we could defer loading of pod namespace code to the require of that namespace. This would work for sci since we have control over
require
. For Clojure it would be slightly more complicated. We'd probably have to patchload
to take control over loading pod namespaces:I did a quick experiment with this (see lazy-namespaces branches in babashka and babashka.pods).
I did have to introduce extra
require
s to explicitly load the namespace dependencies in the right order:The net win compared to loading all the namespaces during startup doesn't seem to be so big here since this example still requires the namespaces that are macro heavy:
However, this example does much better:
Alternatives:
Custom require for pods:
(pods/require 'retrogradeorbit.bootleg.enlive :as enlive)
Pods only declare their namespaces in describe, but not the associated vars. With
pods/require
(syntactically the same asrequire
) pod namespaces get loaded.This would be easier to implement for both sci and Clojure. We could still support the old way of loading pods. Syntactically it would be less appealing and would require configuration for clj-kondo.
The text was updated successfully, but these errors were encountered: