This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-22
Channels
- # announcements (1)
- # babashka (94)
- # beginners (11)
- # biff (9)
- # calva (21)
- # clj-kondo (14)
- # clojure (12)
- # clojure-europe (56)
- # clojure-nl (1)
- # clojure-norway (41)
- # clojure-uk (4)
- # clojurescript (4)
- # core-logic (2)
- # gratitude (12)
- # honeysql (1)
- # hoplon (3)
- # hugsql (7)
- # introduce-yourself (2)
- # jobs-discuss (23)
- # leiningen (3)
- # malli (11)
- # off-topic (1)
- # pedestal (11)
- # reagent (3)
- # squint (8)
- # vim (9)
- # xtdb (3)
is it considered bad form to add one's own meta data to bb.edn files? and generally to deps.edn files? is there a blessed way of doing this or just don't do it
It’s fine as along as you use an alias or a qualified keyword eg with your org name in it
I have noticed (I raised this before) that running bb tasks take some time to actually start. I put a println at the start and end of the :init sections expecting to see that happen straight away, however, the delay to start seems to happen before the :init. (I don't know if println buffers so that might be skewing what I am seeing)
Windows. Babashka v1.3.182 running on powershell. I have about 50+ tasks running against a set of clojure files that are about 2300 lines of clojure in about 10 files.
I bet it's the amount of code being loaded in top level :requires
that takes the time. You can verify this by doing a manual:
bb -e '(ns foo (:require ...))
`
of those :requires
Sorry this in in house. That was my suspicion - I am not complaining just an observation.
@U4C3ZU6KX just in case - if you're using taoensso.timbre logging, I've found it really slows down loading
You can maybe lazy-load some namespaces to make startup faster using (requiring-resolve 'foo.bar/the-function)
Thanks @U05NY1NK44W I am not using that.
I am not sure how taoensso.timbre would make stuff load slower since the logger is baked in
@U4C3ZU6KX ok, but then try to remove the top level requires. It will break your code, but you can test if that is it by printing something in your :init
It turned out that I must have thought of using taoensso.timbre
as I had it included in the bb files requires - even though I am not using it in the other parts of of my code (I must have started and not carried it through) taking it out has changed the start time for the better. Thanks @U05NY1NK44W
@U4C3ZU6KX @U05NY1NK44W This surprises me. Can you please make a repro that shows how taoensso.timbre slows down startup time?
$ time bb -e "(require '[taoensso.timbre :as t])"
bb -e "(require '[taoensso.timbre :as t])" 0.02s user 0.01s system 89% cpu 0.026 total
$ time bb -e "(require '[taoensso.timbre :as t]) (t/info :hello)"
2023-11-23T10:35:29.571Z m1.local INFO [user:1] - :hello
bb -e "(require '[taoensso.timbre :as t]) (t/info :hello)" 0.02s user 0.01s system 82% cpu 0.037 total
Thanks @U04V15CAJ All I can say is that with tasks startup it made a difference. Thanks for looking.
@U04V15CAJ, for me it added a 3 second startup time.
@U05NY1NK44W the exact example I wrote above?
Here is the start of my bb.edn file - it has some
{:paths ["src", "test"]
:deps {com.rpl/specter {:mvn/version "1.1.4"}
org.clj-commons/clj-http-lite {:mvn/version "1.0.13"}
metosin/malli {:mvn/version "0.11.0"}
clj-commons/clj-yaml {:mvn/version "1.0.26"}
etaoin/etaoin {:mvn/version "1.0.40"}
com.github.oliyh/martian-babashka-http-client {:mvn/version "0.1.25"}}
:tasks {:requires ([etaoin.api :as e]
[ogsetup.core :as core]
...
[testing :as testing]
[cheshire.core :as json]
[clojure.tools.cli :as cli]
[babashka.curl :as curl]
[babashka.fs :as fs]
[taoensso.timbre :as timbre])
:init (do
(def cli (cli/parse-opts *command-line-args* core/cli-options))
(def options (:options cli))
(utils/set_config (utils/read-edn-file "" (:config options)))
(utils/set-user (:user options))
(when (:info options) (do (utils/set-verbosity :info) (add-tap println) (timbre/set-level! :info)))
(when (:debug options) (do (utils/set-verbosity :debug) (add-tap println) (timbre/set-level! :debug)))
(when (:help options) (println (:summary (cli/parse-opts *command-line-args* core/cli-options))))
(utils/tapd-> (utils/get_config (utils/get-user)))
(utils/tapd-> options))
help (println (:summary (cli/parse-opts *command-line-args* core/cli-options)))}
Sorry it has cruft that you won't need but just removing the timbre lines - improved the performance
@U04V15CAJ just tried your example
time bb -e "(require '[taoensso.timbre :as t]) (t/info :hello)" 2023-11-23T12:59:13.896Z UnknownHost INFO [user:1] - :hello ______________________________________________________ Executed in 5.01 secs fish external usr time 8.64 millis 384.00 micros 8.26 millis sys time 3.83 millis 117.00 micros 3.72 millis
@U4C3ZU6KX A standalone example would be something like:
{:paths ["src", "test"]
:deps {com.rpl/specter {:mvn/version "1.1.4"}
org.clj-commons/clj-http-lite {:mvn/version "1.0.13"}
metosin/malli {:mvn/version "0.11.0"}
clj-commons/clj-yaml {:mvn/version "1.0.26"}
etaoin/etaoin {:mvn/version "1.0.40"}
com.github.oliyh/martian-babashka-http-client {:mvn/version "0.1.25"}}
:tasks {:requires ([etaoin.api :as e]
[cheshire.core :as json]
[clojure.tools.cli :as cli]
[babashka.curl :as curl]
[babashka.fs :as fs]
[taoensso.timbre :as timbre])
:init (do
(def cli (cli/parse-opts *command-line-args* {}))
(def options (:options cli))
(when (:info options) (timbre/set-level! :info))
(when (:debug options) (do (add-tap println) (timbre/set-level! :debug)))
(when (:help options) (println (:summary (cli/parse-opts *command-line-args* {})))))
help (println (:summary (cli/parse-opts *command-line-args* {})))}
}
without any external cruft. Either that or provide a github repro I can run locally. Can't reproduce with this example.@U05NY1NK44W Interesting
Ok sorry @U04V15CAJ, I will try.
@U4C3ZU6KX, did you run @Borkdudes example, do you have a hostname ok?
ritchie@blackdog ~> bb -e '(.getHostName (http://java.net.InetAddress/getLocalHost))' ----- Error -------------------------------------------------------------------- Type: java.net.UnknownHostException Message: blackdog: blackdog: Try again Location: <expr>:1:1 ----- Context ------------------------------------------------------------------ 1: (.getHostName (http://java.net.InetAddress/getLocalHost)) ^--- blackdog: blackdog: Try again ----- Stack trace -------------------------------------------------------------- user - <expr>:1:1
Executed in 5.01 secs fish external usr time 6.38 millis 0.00 micros 6.38 millis sys time 3.72 millis 508.00 micros 3.21 millis
https://stackoverflow.com/questions/33289695/inetaddress-getlocalhost-slow-to-run-30-seconds
@U4C3ZU6KX try the snippet and find out
time bb -e '(.getHostName (http://java.net.InetAddress/getLocalHost))' "blackdog" ______________________________________________________ Executed in 11.89 millis fish external
powershell:
Measure-Command {start-process bb get-help -Wait}
Days : 0
Hours : 0
Minutes : 0
Seconds : 2
Milliseconds : 348
Ticks : 23487645
TotalDays : 2.71847743055556E-05
TotalHours : 0.000652434583333333
TotalMinutes : 0.039146075
TotalSeconds : 2.3487645
TotalMilliseconds : 2348.7645
summary: my hostname in /etc/hostname was blackdog, but this was not entered into /etc/hosts
I think this may be because on windows the concept of hostname may be different so could be the same issue.
@U4C3ZU6KX what was the return value...?
It would normally have given the cli help output, but Measure-command seems to swallow the return value.
C:\Users\borkdude>bb -e "(.getHostName (java.net.InetAddress/getLocalHost))"
"DESKTOP-JN2UNTV"
@U05NY1NK44W good news!
@U4C3ZU6KX can you try the same thing as I did above in cmd.exe or powershell?