This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-26
Channels
- # asami (3)
- # babashka (3)
- # beginners (45)
- # boot (3)
- # calva (6)
- # clojure (26)
- # clojure-dev (16)
- # clojure-europe (15)
- # clojure-norway (6)
- # clojure-uk (6)
- # clojurescript (34)
- # community-development (4)
- # conjure (3)
- # datascript (4)
- # datomic (4)
- # emacs (21)
- # events (1)
- # fulcro (16)
- # graalvm (5)
- # jackdaw (1)
- # kaocha (5)
- # lsp (74)
- # malli (8)
- # nbb (37)
- # off-topic (50)
- # pathom (5)
- # reagent (19)
- # ring (1)
- # shadow-cljs (60)
- # sql (3)
I’m trying to optimize a clojure (jvm) service that uses some datascript (1.3.8) entities on its hot path. They are returned by a query and then later we use them as we would use nested maps:
(d/q '[:find ?entity ; and other stuff
:where
; other clauses
[(datascript.core/entity $ ?foo) ?entity]]
db)
(-> entity :foo/bar :foo.bar/baz)
(-> entity :qux/_some-reverse-lookup :foo/bar :foo.bar/baz)
(contains? entity :foo/bar)
;; etc
We found through flame graphs that a noticeable amount of time is spent in these keyword lookups (more specifically in lookup-entity
) despite the built-in caching.
I feel like we are missing a better pattern here and was wondering what we could do at query time to speed up later lookups within the entity?