This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-29
Channels
- # aws (16)
- # beginners (14)
- # boulder-clojurians (1)
- # braveandtrue (184)
- # cider (9)
- # cljs-dev (17)
- # cljsrn (10)
- # clojure (70)
- # clojure-austin (16)
- # clojure-finland (2)
- # clojure-germany (4)
- # clojure-italy (6)
- # clojure-nl (6)
- # clojure-sanfrancisco (2)
- # clojure-spec (5)
- # clojure-uk (60)
- # clojurescript (82)
- # cursive (1)
- # data-science (1)
- # datomic (13)
- # defnpodcast (1)
- # docker (82)
- # figwheel-main (18)
- # fulcro (51)
- # funcool (6)
- # jobs (13)
- # jobs-discuss (5)
- # jobs-rus (7)
- # juxt (2)
- # leiningen (4)
- # lumo (5)
- # mount (1)
- # off-topic (38)
- # pedestal (9)
- # re-frame (13)
- # reagent (16)
- # shadow-cljs (70)
- # spacemacs (5)
- # specter (9)
- # sql (8)
- # tools-deps (2)
- # vim (6)
generally, # introduces reader macros, #{} is a data literal for a set
Different angle on the same thing
I was just noticing that in Clojure, when you reverse a vector before looping over it, it goes a little faster. π
So does that mean that things like map
might go faster on vectors if they always reversed them first, then looped on them from the tail backward, to get the original mapping order?
@john range
produces something very specific (not a vector, as you observed).
I'd also say you're not getting accurate timings doing one-offs with time
. Take a look at criterium for running benchmarks more reliably.
If you replace (range 10000)
with (vec (range 10000))
to get an actual Clojure vector, it is significantly faster than either of the first two expressions you gave, according to a Criterium run, i.e. 200 to 300x faster.
Also, if you use Criterium and Leiningen, the default Leiningen REPL starts a JVM with command line options intended to speed startup time, at the likely expense of long-term optimizations that a JVM JIT can do for you.
See the project.clj of this project for an example of how to make Leiningen not do that: https://github.com/jafingerhut/funjible-test-project/blob/master/project.clj#L15-L19
I agree the difference in access time between (range 10000)
and (reverse (range 10000))
is a little weird, but maybe not a performance bug. (range 10000)
I believe tries to save memory by calculating the entry values on demand.
Yeah, range
is lazy, so it makes more sense to use when you want to realize values one by one, on demand. Perhaps because you expect to only use a subset of them, or because itβs awkward to fit it all in memory at once.
Hey, when I look at this https://pkgs.alpinelinux.org/packages it seems clojure isn't in the alpine repos
@andy.fingerhut @seancorfield @henrik yeah, I might crack open the ol' criterium and get a more solid picture of that reverse behavior
@urbanslug I think some other common docker OS targets have clojure
in their repos. It'd be awesome to have an alpine package though.
But, worst case, you could install java on there and then install clojure on top as part of a startup script... Ah
You could probably just rejigger the clojure
install scripts from one of the other distros for alpine
I was hoping to just apk add clojure
> naw bring the clojure jar into the docker as an external dep
Looks like this is one way to accomplish that: https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package
But they also say you can just 'submit an issue' here https://bugs.alpinelinux.org/projects/alpine/issues and request it as a 'feature' and they may build it for you.
hmmm but I'd have to maintain it. Ok I'll look into that. > Looks like this is one way to accomplish that: https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package
I found it very useful to make a custom docker image, otherwise you always redownload your deps on startup
Or you can mount your local .m2 with the container. docker run -v $HOME/.m2:/root/.m2 clojure:tools-deps ...
that doesn't work optimally with my company's specific marathon based infrastructure where nodes get recycled, but yeah, that can help too
I noticed this and I'm thinking of caching ~/.m2 > I found it very useful to make a custom docker image, otherwise you always redownload your deps on startup
What about CI?
> Or you can mount your local .m2 with the container. docker run -v $HOME/.m2:/root/.m2 clojure:tools-deps ...
Depends on your service. In circleci it is about adding save_cache directive with a key prefixed with check sum of deps.edn
I'm using chime-at, which periodically calls an fn. it doesn't accept a collection of fns. how would I be able to alternate between two different fn calls?