JavaScript Jam Live on Wednesday
Join us this Wednesday for another open mic to discuss all the JavaScript news of the week. Last week, we discussed announcements from Google I/O about changes to Core Web Vitals. We were also joined by Monica Powell to hear about her upcoming RenderATL talk on creative coding. Check out the recording below:
Stories of the Week
State of Node.js Performance 2023
Node.js TSC member Rafael Gonzaga has created an incredible resource for JavaScript performance nerds and published it under the title, State of Node.js Performance 2023. The article presents a comprehensive performance analysis of different Node versions, focusing on versions 16.20.0, 18.16.0, and 20.0.0. Three benchmark groups were utilized in his research:
- Node Internal Benchmark: An opinionated set of benchmarks grouped by module targeting high-impact operations for Node developers.
- nodejs-bench-operations: An open source repository with benchmark operations for all major Node versions, including the last three releases of each version line.
- HTTP Servers: A pragmatic HTTP benchmark that uses Express and Fastify to send requests to various routes and return JSON, plain text, and errors. The results for this group will be published in a subsequent article.
The analysis used an AWS Dedicated Host with a c6i.xlarge
computing-optimized instance. The benchmarks covered various Node modules/namespaces, such as fs
(file system), events (EventEmitter
/EventTarget
), http
(HTTP server + parser), and more.
The statistical method applied in the study required performing each benchmark several times. The data was analyzed to determine the percentage of performance improvement along with a level of confidence in the improvements. Key findings include:
- File System (
fs
): An improvement of 67% was observed when upgrading from Node 16 to 18 usingfs.readfile
API withascii
encoding. However, there was a regression of 27% in Node 20 which is expected to be addressed in future minor releases. Otherfs
methods likeopendir
,realpath
, andreaddir
showed improvement from Node 18 to 20. EventTarget
: Event dispatching performance improved by about 15% when upgrading from Node 16 to 18 and up to 200% when upgrading from Node 18 to 20 with a single listener.- HTTP Servers: An 8% improvement was noticed from Node 16 to 18 and a seemingly massive 96.13% improvement was found from Node 18 to 20. However, other more reliable benchmarking tools only showed an improvement of 9%, suggesting limitations or errors in the previous benchmarking method.
startup.js
: Significant improvement in the Node process lifecycle was observed with a 27% boost from Node 18 to 20 and 34.75% from Node 16 to 20.trace_events
: Observed a 7% improvement from Node 16 to 20 and a 2.39% improvement from Node 18 to 20.require()
: Observed improvements between Node 18 and 20 when requiring.js
files (4.20%),.json
files (6.58%), and reading directories (9.50%), thus contributing to faster startup times.- Streams: Some operations related to streams became slower between Node 16 and 18. Also, certain types of streams (like
Transform
) regressed in Node 20. - URL Parsing: The introduction of the Ada URL parser in Node 18 resulted in performance improvements of up to 400% when parsing URLs, with further enhancements observed in Node 20 due to an upgrade to Ada 2.0.
- Buffers: Node 20 fixed two major regressions from Node 18 and showcased significant improvements in handling binary data, particularly in
Buffer.concat()
andBuffer.toJSON()
functions, making it the fastest version for dealing with buffers. - Text Decoding and Encoding: Node 20 brought substantial performance improvements in
TextDecoder
andTextEncoder
over Node 18, with the addition ofsimdutf
for UTF-8 parsing leading to a 364% improvement in decoding and a 25% performance boost in comparison to Node 18.
While the overall benchmark results show a few setbacks, most of the areas of concern demonstrate that significant improvements were made in Node's performance across versions 16, 18, and 20. Most importantly, these benchmark results can help guide future optimizations and assist in avoiding regressions.
Bun v0.6
Dubbed, "the biggest release of Bun yet," Bun v0.6 introduces a built-in JavaScript and TypeScript bundler and minifier. Users can now bundle their frontend apps or convert code into standalone executables (meaning they do not require a Bun installation for execution). v0.6.2 quickly followed with numerous performance improves and then v0.6.3 added support for node:vm
.
The bundler is seen as the first step towards Bun.App
, an integrated API combining Bun's bundler, HTTP server, and file system router. The bundler can be used through the bun build
CLI command or the new Bun.build()
JavaScript API. Other key features and improvements include:
import.meta.main
can be used to check if the current file is the entry point that started Bun.- New testing methods were added and
bun test
now reports test run times. - Performance enhancements include a 20% speed increase for
writeFile()
on Linux. - Improvements to Node.js and Web API compatibility.
Quick Links
- Hoh Shen Yien - The Next.js 13 App Directory and Server Components: What You Need to Know
- Ryan Toronto - Building a users table with a server component
- Artem Zakharchenko - My Struggle With Remix
- Danny Moerkerke - How To Hydrate A Server-Side Rendered Web Component
- Dominic Elm - The Atomic Waltz: Unraveling WebAssembly Issues in V8 and SpiderMonkey
- Jaimie McMahon - Why the modern web loves Astro and Eleventy
- Tammy Everts - A Complete Guide to Performance Budgets
Composability Summit
In Thomas Heinrichs' talk, Loosely or Lousily Coupled, Thomas aims to explore various composable communication methods in modern distributed architectures, including event streaming, asynchronous messaging, and REST. He discusses their limitations, tradeoffs, and impacts on component coupling while emphasizing how these concepts influence architecture and team productivity.
Podcasts of the Week
- SyntaxFM - WTF are Signals and Why is Everyone So Hot on Them?
- The Vanilla JS Podcast - Accessibility with Ben Myers
- JavaScript Jabber - React Server Components: Part 1 with Dan Abramov
- Frontend First - What Problems do React Server Components Solve?
- PodRocket - Next.js 13.4 with Tim Neutkens
One More Thing
While at Remix Conf, I had the pleasure of interviewing Glauber Costa (CEO of Turso) and Igor Minar (Senior Director of Engineering at Cloudflare). We discussed the future of developing web applications at the edge and how databases and web frameworks will influence the way those applications are built. You can check out the recording here:
JavaScript Jam on the Web
Find us online at the following links: