Created
July 28, 2025 21:56
-
-
Save escherize/cfd846e27209fcd945cfa986fc5c1675 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns mage.escherize.analyze-cache-misses | |
(:require | |
[clojure.edn :as edn] | |
[clojure.java.io :as io] | |
[clojure.string :as str] | |
[mage.util :as util])) | |
(defn read-log [log-file] | |
(map second (edn/read-string (str "[" (slurp log-file) "]")))) | |
(defn most-common [n coll] | |
(->> coll | |
(frequencies) | |
(sort-by val >) | |
(take n) | |
(mapv reverse))) | |
(defn most-common-cache-misses [log-file] | |
(->> log-file | |
read-log | |
(map :schema-key) | |
(most-common 3))) | |
;; Yo, this indicates that we are MISSING the cache for this schema. | |
(most-common-cache-misses "app-startup-master.edn") | |
;; => [(115 "#object[clojure.core$simple_keyword_QMARK_ 0x4d3f8662 \"clojure.core$simple_keyword_QMARK_@4d3f8662\"]") | |
;; (89 ":metabase.lib.schema.expression/base-type") | |
;; (89 "[:= :-]")] | |
(most-common-cache-misses "mlv2-test-master.edn") | |
;; => [(115 "#object[clojure.core$simple_keyword_QMARK_ 0x2e38e93a \"clojure.core$simple_keyword_QMARK_@2e38e93a\"]") | |
;; (89 ":metabase.lib.schema.expression/base-type") | |
;; (89 "[:= :-]")] | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on fixed branch ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; giant schemas, probably race conditions: | |
(most-common-cache-misses "mlv2-test-fix-branch.edn") | |
;; => [(13 [:maybe :metabase.lib.schema.drill-thru/drill-thru]) | |
;; (8 :metabase.lib.drill-thru.object-details/object-detail-drill-out) | |
;; (8 | |
;; [:merge [:merge [:merge .... [:map [:expected-query :map] [:drill-args {:optional true} [:maybe [:sequential :any]]]]])] | |
;; `(def Filter [:ref ::Filter])` has 32 uses | |
(most-common-cache-misses "app-startup-fix-branch.edn") | |
;; => [(3 :metabase.lib.test-util.metadata-providers.mock/mock-metadata) | |
;; (2 | |
;; [:map | |
;; [:key :keyword] | |
;; [:db-schedule-column :keyword] | |
;; [:job-class :metabase.sync.task.sync-databases/class] | |
;; [:name :string]]) | |
;; (2 :metabase.lib.schema.metadata/card)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment