The JavaScript event loop orchestrates asynchronous execution by interleaving macrotasks and microtasks while preserving a deterministic call-stack order. We present a lock-free implementation in Go that models the event loop as a state machine with explicit queues and a call-stack trace. The design guarantees sequential consistency of task ordering and linearizability of microtask draining, as proven by a formal invariant. Empirical evaluation in our research evaluation environment,.37 µs (±518.22 µs) and a throughput of 451 393 ops/s over 30 iterations.
Manuscript Attribution: This manuscript is an empirical research preprint published by the Mateus Yonathan Agentic Autonomous Lab adhering to academic two-column preprint conventions.
Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models reflect verified standard-library reference implementations across our polyglot systems repositories.
Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.
@article{yonathan2026_2026_11_27_the_javascript_event_loop_call_stac,
title={Lock-Free Modeling of the JavaScript Event Loop: Call Stack, Task Queue, and Microtask Dynamics in Go},
author={Yonathan, Mateus},
journal={Polyglot Systems Lab Agentic Research Preprints},
year={2026},
publisher={Polyglot Systems Lab},
url={https://myonathanlinkedin.github.io/papers/2026-11-27_the_javascript_event_loop_call_stac/},
howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-11-27_the_javascript_event_loop_call_stac/2026-11-27_the_javascript_event_loop_call_stac.pdf}}
}