Bun Adds Shared-Memory Threads to JavaScriptCore
Bun open PR for shared-memory threads in JavaScriptCore

A recent open PR on GitHub proposes adding shared-memory threads to JavaScriptCore, a significant development for the JavaScript ecosystem. This feature would enable true parallelism in JavaScript, allowing developers to run functions on separate threads while sharing the same heap and objects. The implications of this change are substantial, as it could fundamentally alter how JavaScript applications are designed and developed. ## What happened The PR, submitted by Jarred-Sumner, introduces a new Thread function that allows running functions on separate threads, all within the same heap and with access to the same objects. This approach eliminates the need for structured cloning, message passing, or relying on SharedArrayBuffer as an escape hatch. The implementation has made significant progress, with parallel JavaScript execution through all four JIT tiers and the thread test suite now passing without a global lock. However, the PR is still in its experimental phase and requires further work, including thread-sanitizer cleanup, fuzzing, and benchmarking. ## Why it matters The addition of shared-memory threads to JavaScriptCore matters because it addresses a long-standing limitation of JavaScript: its single-threaded nature. By enabling true parallelism, developers can create more efficient and scalable applications. This feature could particularly benefit applications that rely heavily on computational tasks, such as scientific simulations, data processing, and machine learning. The change also aligns with the broader trend of increasing parallelism in software development, driven by the growing availability of multi-core processors.
- Enables true parallelism in JavaScript, improving performance and efficiency.
- Simplifies development by allowing shared access to objects and eliminating the need for complex messaging protocols.
- Could lead to significant advancements in applications that rely on computational tasks.
- Introduces complexity and potential risks associated with shared-memory concurrency, such as race conditions and memory leaks.
- May require significant changes to existing codebases and development practices.
- Could lead to increased memory usage and potential performance issues if not managed properly.
What are shared-memory threads in JavaScriptCore?+
How do shared-memory threads differ from workers in JavaScript?+
What are the potential benefits and risks of using shared-memory threads in JavaScriptCore?+
- engineering·3 min readPrefer Duplication Over Wrong Abstraction
Duplication is far cheaper than wrong abstraction
- engineering·3 min readGoogle Reaches 50% IPv6 Milestone
Google hits 50% IPv6 usage, a historic milestone
- engineering·3 min readThe European Social Stack Initiative
Europe launches social stack initiative