Closed kawas44 closed 2 years ago
Hello,
I am using tempura with a dictionary hash-map stored in an atom. An during my application lifetime it happens that I update the atom value.
Everything works fine, but I observe a drop in performance:
I have tried to invalidate the memoized cache using special args but it does nothing. (See code below)
Code example I used to bench tr calls:
;; assume existence of those vars: ;; make-tempura-dict: function to load a new edn dictionary ;; pick n keys from the dict for successive benchs in a row (defn pick-keys [dict lang n] (take n (random-sample 0.5 (keys (get dict lang))))) ;; dummy function to bench something (defn sum-all-trad-count [tr langs ks] (reduce (fn [acc-a l] (reduce (fn [acc-b k] (+ acc-b (count (tr [l] [k])))) acc-a ks)) 0 langs)) (defn bench-tr [langs n] (let [dict (atom (make-tempura-dict)) ks (pick-keys @dict :en n) tr (partial tempura/tr {:dict @dict :cache-dict? true :cache-locales? false}) _ (cr/quick-bench (sum-all-trad-count tr langs ks)) ;; try to clear tr cache _ (tr [:mem/del :mem/all] [:mem/del :mem/all]) new-dict-value (make-tempura-dict) _ (swap! dict (constantly new-dict-value)) tr (partial tempura/tr {:dict @dict :cache-dict? true :cache-locales? false}) _ (cr/quick-bench (sum-all-trad-count tr langs ks))] (println "done."))) ;; run benchmarks #_ (bench-tr [:en :es :fr] 10)
Do you have any insights on how to use an updated dict value and keep a good performance ?
Thanks
Closing old question as part of issue triage, but please feel free to reopen if this is still a concern. In which case a ready-to-run example project would be super helpful - thanks!
Hello,
I am using tempura with a dictionary hash-map stored in an atom. An during my application lifetime it happens that I update the atom value.
Everything works fine, but I observe a drop in performance:
I have tried to invalidate the memoized cache using special args but it does nothing. (See code below)
Code example I used to bench tr calls:
Do you have any insights on how to use an updated dict value and keep a good performance ?
Thanks