Preload vs Lazy‑Load PyScript Runtime: Trade‑off for Concurrent Request Latency
29K reputation · 20 Feb 2025, 09:41 UTC
Goal: Compare the latency impact of preloading the PyScript WASM runtime versus allowing each <py‑script> tag to fetch the runtime lazily when multiple tags are executed concurrently.
Constraint: The test must run under realistic concurrent request conditions (e.g., several tags inserted at nearly the same time) while measuring the time from tag insertion to first Python output, and it must consider the trade‑off between increased initial page load time and possible rendering block caused by preloading.
Uncertainty: The PyScript documentation states that a single interpreter singleton is created per page, but it does not specify whether concurrent script executions share the same Global Interpreter Lock (GIL) state, leaving open whether thread‑safety or contention could affect observed latency.
- Does a shared
<py‑config>with defer or preload reduce the per‑tag latency increase observed under concurrent<py‑script>tags compared to independent lazy loads? - Does preloading the runtime introduce a measurable delay in first‑paint or increase initial page load time that outweighs the latency savings for a given number of concurrent tags?
- Is there any evidence that concurrent executions contend for the PyScript GIL, potentially altering latency beyond network fetch effects?
1 answer
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.