Running the file generation in parallel netted a nice speedup of nearly 25% (bench below). I tried adding FIFO caches to the path generation too, but the overhead swamped any gains given - mean execution rose almost 90%. For reference, that code was
Running the file generation in parallel netted a nice speedup of nearly 25% (bench below).
I tried adding FIFO caches to the path generation too, but the overhead swamped any gains given - mean execution rose almost 90%. For reference, that code was

;; FIFO caches use default eviction threshold of 32 entries
(def parent-route-cache (atom (cache/fifo-cache-factory {:threshold 64})))
(def child-route-cache (atom (cache/fifo-cache-factory {:threshold 64})))

(defn gen-route-parent*
  "Generate a route to the top destination from the current destination"
  [loc acc]
  (let [parent (-> loc z/up z/up)
        loc-id (-> loc z/node :attrs :id)]
    (if parent (recur parent (cons loc-id acc)) (cons loc-id acc))))

(defn gen-route-parent
  "FIFO-cache backed version of gen-route-parent*"
  [loc acc]
  (if (cache/has? @parent-route-cache loc)
    (do
      (swap! parent-route-cache #(cache/hit % loc))
      (concat acc (cache/lookup @parent-route-cache loc)))
    (swap! parent-route-cache
           #(cache/miss % loc (gen-route-parent* loc acc)))))

(defn gen-route-child*
  "Generate a route to the bottom destination from the current destination, taking the left-most child if any"
  [loc acc]
  (let [loc-id (-> loc z/node :attrs :id)
        child-test (-> loc z/down z/right)]
    (if child-test (recur (z/down child-test) (conj acc loc-id)) (conj acc loc-id ))))

___________________

Final benchmark

Evaluation count : 900 in 60 samples of 15 calls.
             Execution time mean : 79.978478 ms
    Execution time std-deviation : 22.784280 ms
   Execution time lower quantile : 67.187660 ms ( 2.5%)
   Execution time upper quantile : 139.795484 ms (97.5%)
                   Overhead used : 3.376706 ns

Found 7 outliers in 60 samples (11.6667 %)
	low-severe	 2 (3.3333 %)
	low-mild	 5 (8.3333 %)
 Variance from outliers : 96.3668 % Variance is severely inflated by outliers

OliverM/lonelyplanet