This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-23
Channels
- # aws-lambda (1)
- # beginners (11)
- # boot (456)
- # cider (3)
- # cljsrn (7)
- # clojure (340)
- # clojure-berlin (6)
- # clojure-dev (207)
- # clojure-germany (12)
- # clojure-greece (3)
- # clojure-italy (3)
- # clojure-russia (12)
- # clojure-spec (42)
- # clojure-uk (29)
- # clojured (7)
- # clojurescript (125)
- # datascript (1)
- # datomic (47)
- # defnpodcast (4)
- # emacs (30)
- # events (7)
- # hoplon (13)
- # instaparse (64)
- # jobs (13)
- # jobs-discuss (1)
- # lein-figwheel (1)
- # leiningen (10)
- # luminus (1)
- # lumo (14)
- # off-topic (10)
- # om (16)
- # om-next (3)
- # onyx (1)
- # pedestal (3)
- # protorepl (5)
- # re-frame (17)
- # reagent (66)
- # ring (1)
- # ring-swagger (13)
- # spacemacs (12)
- # specter (4)
- # untangled (272)
- # vim (4)
- # yada (24)
@ddellacosta watch out - set-based specs dont work for false and nil
Is anyone using caching/memoize type techniques to avoid instrumentation cost? Say keeping a cache of hash values for data which has been checked so that future checks are cheap.
@olivergeorge Given that instrument
should be a dev/test-only activity, does performance matter?
@seancorfield in this case it causes odd performance
Laggy data input etc. In my case: checking the full definition of a complex form at each function/api call.
Well, yes, instrument
has an overhead. Of course.
Something you keep an eye out for when developing. Nice not to have false positives.
@seancorfield not if performance doesnt matter.
Yeah. I appreciate that. Love spec. Caching would work. Just wondering if anyone has looked into using it.
If you have an implementation function and then a wrapper -- and the wrapper is memoized -- then instrumenting the implementation should only apply the overhead for each new set of arguments (and this seems the right way to deal with it).
I'd consider very slow/erratic behavior of an instrumented function to be a good indicator that I might need to cache/memoize the function anyway...?
(happy to be proved wrong but that's my initial intuition)
Thanks. I see what you mean about wrapping a specific fn. That would do the trick for specific cases.
@seancorfield any chance you know of a fifo memoize implementation for cljs?
(worried that a long running SPA would gobble memory with memoize in the wrong place)
We can hope that core.cache and core.memoize get converted to .cljc
perhaps?
That does sound ideal.
(and we just got that functionality in the CI support for contrib projects so...)
As to your original Q, no, sorry, I've no idea about memoization for cls otherwise, sorry 😞
to support selective conforming (or protocol extensions) for the spec: http://dev.clojure.org/jira/browse/CLJ-2116
@not-raspberry I was looking for the equivalent of an enum of keywords, so think I’m safe here...
@alexmiller I'm trying to understand if memoizing s/conform is likely to cause problems.
(set! s/conform (memoize (fn [spec x] (s/conform* (s/specize spec) x))))
Biggest risk I see is a spec changing causing the cached results to be invalid.
Seems like the spec arg may vary in nature (keywords vs implementations). Perhaps it's better to memoize after calling (specize spec) ?same problems as usual with memoize:
1) it’s an unbounded cache, which only fills up at 3 am in production
2) you won’t see effects of any stateful changes (if in your repl, probably from changing specs). but if you made calls to anything stateful, you won’t see changes.
@bbloom only on daylight savings change
but specs are built with a delay anyways, which is forced on first use
so they effectively already cache the spec conform implementation and won’t see changes if you change specs after use anyways
so that’s maybe only a small downside
so I have a s/keys
spec with :opt
fields. When I use (gen/generate (s/gen ::my-spec)
it generates them with :req fields and skips :opt fields. Is there a way to force :opt fields to be added?
generate starts out with the simplest possible values and gets more complicated as it goes