This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-22
Channels
- # announcements (2)
- # asami (123)
- # aws (17)
- # babashka (77)
- # babashka-sci-dev (23)
- # beginners (48)
- # biff (6)
- # calva (35)
- # cider (16)
- # clj-on-windows (1)
- # clj-yaml (19)
- # clojure (36)
- # clojure-europe (78)
- # clojure-nl (5)
- # clojure-norway (8)
- # clojure-poland (3)
- # clojure-uk (16)
- # clojurescript (17)
- # cursive (6)
- # datahike (3)
- # datalevin (26)
- # duct (7)
- # emacs (41)
- # events (2)
- # fulcro (7)
- # graphql (5)
- # honeysql (13)
- # juxt (3)
- # kaocha (7)
- # lsp (5)
- # malli (12)
- # off-topic (14)
- # pathom (3)
- # portal (1)
- # rdf (9)
- # reitit (3)
- # remote-jobs (2)
- # shadow-cljs (37)
- # spacemacs (5)
- # tools-build (1)
- # tools-deps (20)
- # xtdb (2)
Found some performance improvement opportunities around parsing, especially around regex parsers. Also, trying to fold and/or parsers, but it's confusing 🙃
Would appreciate a pointer regarding what I'm getting wrong with orn
this is the or
parser:
(defn- -or->parser
[children]
(fn [f]
(let [parsers (-vmap f children)]
#?(:clj
(reduce
(fn [acc parser]
(fn [data]
(let [parsed (acc data)]
(if (miu/-invalid? parsed)
(parser data)
parsed))))
(fn [_] ::invalid)
(reverse parsers))
:cljs
#(reduce (fn [_ parser] (miu/-map-valid reduced (parser %))) ::invalid parsers)))))
And the orn
parser doesn't work
(defn- -orn->parser
[this]
#?(:clj
(reduce
(fn [acc [k _ c]]
(let [parser (-parser c)]
(fn [data]
(let [parsed (acc data)]
(if (miu/-invalid? parsed)
(parser data)
(miu/-tagged k parsed))))))
(fn [_] ::invalid)
(reverse (-children this)))
:cljs
(let [parsers (-vmap (fn [[k _ c]]
(let [c (-parser c)]
(fn [x] (miu/-map-valid #(reduced (miu/-tagged k %)) (c x)))))
(-children this))]
(fn [x] (reduce (fn [_ parser] (parser x)) x parsers)))))
Anyway, first MR which I'm sure of submitted. Would you like to see before/after comparisons?
I decided to break things apart and start with the improvements I'm sure of https://github.com/metosin/malli/pull/756
One radical thing I've considered trying is pivoting the values array in the Cache to as many arrays as CacheEntry has fields, avoids allocation and makes the entire thing cache friendly
after a comment by Thomas Heller (https://github.com/metosin/malli/pull/754#issuecomment-1252581659) I refactored the cljs function instrumentation https://github.com/metosin/malli/pull/755 to happen all in cljs with only collecting schemas happening in a macro. The benefits include the namespaces matching with the clojure versions (aside from malli.dev.cljs
), a simpler mental model as instrumentation doesn't occur via generated code, and a more straight forward implementation that matches clojure's pretty closely.
When working with Malli and generators, how do folks typically handle lazy loading of test.check?
https://github.com/borkdude/dynaload is great for this sort of thing
Cool lib :thumbsup::skin-tone-2: How do you set the generator on a schema to be dynamically loaded? i.e., if I'm setting :gen/gen
key, it'd need to be loaded when setting it.
i haven't done it myself, but perhaps walking the schema dynamically to produce a new schema? https://github.com/metosin/malli#programming-with-schemas the "Adding generated example values to Schemas" section in particular