🔧 Warn at startup when headless wasm export is enabled

This commit is contained in:
Elena Torro 2026-07-27 16:48:36 +02:00
parent 0dbae06c45
commit b9b75805c9
3 changed files with 20 additions and 2 deletions

View File

@ -12,6 +12,7 @@
[app.config :as cf]
[app.http :as http]
[app.redis :as redis]
[app.wasm :as wasm]
[promesa.core :as p]))
(enable-console-print!)
@ -23,6 +24,13 @@
:public-uri (str (cf/get :public-uri))
:internal-uri (str (cf/get-internal-uri))
:version (:full cf/version))
(when (cf/get :wasm-headless)
(l/warn :msg "headless wasm export enabled (experimental)"
:hint (str "renders run in-process on a single shared wasm module "
"and are serialized one at a time, so exports do not "
"run concurrently; not recommended for busy instances")
:wasm-dir (wasm/artifact-dir)
:image-cache-mb (wasm/image-cache-mb)))
(p/do!
(bwr/init)
(redis/init)

View File

@ -442,7 +442,7 @@
;; Trim the image store AFTER the request (never mid-render, so
;; an image can't disappear under a running export). Images the
;; next request needs again are simply re-provisioned.
(let [evicted (wasm/evict-images! (cf/get :wasm-image-cache-mb 256))]
(let [evicted (wasm/evict-images! (wasm/image-cache-mb))]
(when (pos? evicted)
(l/info :hint "wasm render: evicted cached images" :count evicted)))
result))

View File

@ -44,10 +44,20 @@
;; get_fonts_for_shape entry: [uuid 16 bytes][weight u32][style u32].
(def ^:private FONT-ENTRY-BYTES 24)
(defn- artifact-dir
(defn artifact-dir
"Directory holding the built render-wasm artifact (render-wasm.js/.wasm).
The docker image points `PENPOT_WASM_DIR` at the copy shipped inside the
exporter bundle; the default is where `render-wasm/build` leaves it in
devenv."
[]
(cf/get :wasm-dir "../frontend/resources/public/js"))
(defn image-cache-mb
"Byte budget (in MB) the wasm image store is trimmed down to between
requests. See `evict-images!`."
[]
(cf/get :wasm-image-cache-mb 256))
(defn- read-result-bytes
"Reads `len` bytes from the WASM heap starting at `offset`, copying them out
(via `.slice`) before the buffer is freed."