Axonpack

Benchmarks

Render time, memory and file size for axonpdf and react-pdf 4.9.0 in a browser Web Worker, and for axonpdf, react-pdf 4.9.0 and pdfkit 0.21.0 in Node.

These numbers come from bench/ in the axonpdf repository. Every run is logged in bench/RESULTS.md with its date, commit, machine and the command that reruns it.

There are two runs. The browser run of 2026-11-23 is the current one. The Node run of 2026-11-21 used one flowing <Page>, the layout where react-pdf is slowest, and is kept for its pdfkit comparison and the memory work.

In the browser (2026-11-23)

The live benchmark app, bench/live in the axonpdf repository, renders a shipping ledger in the browser: A4, a fixed header with an SVG logo, a "Page n of N" footer, and shipments of 4 to 12 lines each with wrapped notes. You can run it yourself at axonpdf-demo.axonpack.dev.

Machine: Apple M4 with 10 cores, 24 GB RAM, macOS 27.2.1, Chrome for Testing 156.0.8078.4 (new headless, through Playwright). Run on 2026-11-23 with the app at commit 8aa5dca, and the engines from npm: @axonpdf/react 0.0.1 and react-pdf 4.9.0. Both engines render in a Web Worker. One run per cell, each in a fresh browser. A run with no PDF after 10 minutes was stopped.

The ledger comes in two layouts with the same data:

  • Sections puts the summary on its own <Page>, then one <Page> per day of shipments, 28 in all. This is how real reports are usually built. The largest section is about 4 pages at 100, 19 at 500 and 74 at 2000. Each section ends on a part-filled page, so the page counts run a few percent over the target.
  • One flowing page puts everything in a single <Page>.

What the columns mean:

  • Time to PDF is from the render call to the finished PDF Blob.
  • Longest freeze is the longest gap between frames on the page's main thread. Both engines run in the worker, so the page stays responsive for both.
  • Worker heap peak is the worker's JavaScript heap, read through the Chrome DevTools Protocol (Runtime.getHeapUsage, what DevTools' Memory panel shows) about once a second. A render that finishes in under a second may get no sample. For a stopped run it is the peak up to then.

Sections

EngineTarget pagesPagesTime to PDFFile sizeLongest freezeWorker heap peak
axonpdf1001120.90 s382 KB19 ms11.6 MB
react-pdf 4.9.01001122.8 s563 KB18 ms192.5 MB
axonpdf5004994.1 s1.8 MB19 ms55.9 MB
react-pdf 4.9.050049945.8 s2.7 MB18 ms2230 MB
axonpdf2000196415.9 s7.1 MB18 ms141.6 MB
react-pdf 4.9.02000-no PDF after 10 min--3158 MB when stopped

At 2000 pages react-pdf didn't finish: its sections are about 74 pages each, and its heap passed 3 GB before the run was stopped.

One flowing page

EngineTarget pagesPagesTime to PDFFile sizeLongest freezeWorker heap peak
axonpdf100980.86 s362 KB18 msnot sampled (under 1 s)
react-pdf 4.9.01009832.8 s539 KB19 ms560.1 MB
axonpdf5004873.9 s1.8 MB19 ms39.2 MB
react-pdf 4.9.0500-no PDF after 10 min--2458 MB when stopped

react-pdf's time grows with the square of how many pages one <Page> wraps onto, so the same report in one flowing page takes it far longer than in sections. axonpdf's time grows with the page count in both layouts.

Rerunning a cell

cd bench/live && npm ci && npm run build && npm run preview

For each cell, open the page, pick the layout, the page count and the engine (worker thread), and Render. The published numbers come from a scripted Playwright run, one per cell, which reads the worker heap through the DevTools Protocol.

In Node, one flowing <Page> (2026-11-21)

What was measured

One A4 report in a single <Page>, rendered at 100, 1000 and 5000 pages. Each page has a header with a logo, and the footer says "Page n of N". The first page has three paragraphs, and a bordered five-column table starts under them and runs to the last page, with its header row repeated on every page.

  • axonpdf and react-pdf 4.9.0 render the same JSX file (bench/report.jsx), where the table rows are an array of elements. react-pdf gets the file through an alias of the @axonpdf/react import, so neither engine has its own version.
  • "rows from a generator" is the same report with the rows passed as a generator child (bench/report-generator.jsx).
  • "rows in <Rows>" puts the rows inside axonpdf's <Rows> component (bench/report-rows.jsx).
  • pdfkit 0.21.0 draws the same pages by hand (bench/report-pdfkit.mjs), with the same page size, fonts, sizes and table. The page breaks are worked out in advance, so pages stream out as they are drawn.

Each run is its own Node process, and runs go one at a time. Time is the render call alone, without Node start-up. Memory is the peak resident set size (RSS) of the whole process. Both React engines ran with NODE_ENV=production.

Machine: Apple M4 with 10 cores, 24 GB RAM, macOS 27.2.1, Node 24.11.0. Run on 2026-11-21 at commit f843e84, which is the engine as of ecb0699 plus the generator version of the benchmark. axonpdf was a development build (version 0.0.0) at that commit.

Results

Engine100 pages1000 pages5000 pages
axonpdf, rows as an array817 ms, 117 MB7.8 s, 154 MB39.2 s, 471 MB
axonpdf, rows from a generator863 ms, 117 MB7.8 s, 130 MB39.2 s, 215 MB
axonpdf, rows in <Rows>527 ms, 129 MB4.8 s, 147 MB24.1 s, 259 MB
react-pdf 4.9.036.1 s, 1289 MBstopped at 15 minnot run
pdfkit 0.21.0145 ms, 97 MB1.1 s, 175 MB5.3 s, 347 MB

Output size, from the same runs:

Engine100 pages1000 pages5000 pages
axonpdf, rows as an array or a generator442 KB4.3 MB21.5 MB
axonpdf, rows in <Rows>447 KB4.3 MB21.7 MB
react-pdf 4.9.0643 KB
pdfkit 0.21.0357 KB3.5 MB17.3 MB

react-pdf's 100-page run is from the same session as the axonpdf and pdfkit runs. Its 1000-page run comes from an earlier session on the same machine with the same react-pdf version: it was stopped at the 15-minute limit while it held 3.5 to 3.7 GB, so the 5000-page size was not tried. Every PDF that finished passed qpdf --check.

The outputs match closely. At 100 pages, axonpdf's first and last pages differ from react-pdf's in 0.13% and 0.12% of their pixels. Most of that is the table's left border: axonpdf draws it and react-pdf doesn't. The generator version is identical to the array version pixel for pixel, and the <Rows> version differs from it in 0.02 to 0.03% of the pixels.

About pdfkit

pdfkit is a lower-level library. You call it to draw text, lines and images at positions you work out yourself, and you decide where each page ends. It has no flexbox and no automatic page breaks. The two React engines read a component tree, lay it out and break the pages for you, and that layout is most of their work. pdfkit is the fastest here because the hand-written version does that work in its own code, ahead of time, for one fixed layout. Read its numbers as a lower bound for what drawing these pages costs.

Long documents without code changes

A document written the usual way needs no changes for long output. axonpdf walks the React elements once and builds long lists of children, and each page's content, only when the engine reaches them. The engine's own memory stays about the same size whatever the page count.

How you pass long lists still makes a difference at large sizes. In the array version, the array of 190,000 row elements stays alive for the whole render. That makes V8 place the elements each row creates in its old generation, where they stay until a full garbage collection, and the process peaked at 471 MB at 5000 pages. Passing the same rows as a generator child avoids it:

function* itemRows(items) {
  for (const item of items) yield <ItemRow key={item.id} item={item} />;
}

// Instead of {items.map((item) => <ItemRow key={item.id} item={item} />)}
<View>{itemRows(items)}</View>

That version peaked at 215 MB at 5000 pages, with the same time and the same output. A generator is an ordinary iterable child in React, so react-pdf renders this code unchanged.

<Rows> for async data

<Rows> is axonpdf's own component for long lists. It takes the rows as an array or an async iterable, such as a database cursor, and renders and writes them in batches. In this benchmark it was the fastest of the axonpdf versions at every size, and it peaked at 259 MB at 5000 pages.

import { Rows } from '@axonpdf/react';

<Rows rows={items} batchSize={200}>
  {(item) => <ItemRow item={item} />}
</Rows>

batchSize defaults to 100. A document that uses <Rows> no longer renders in react-pdf, so use it when the rows come from an async source or when the speed matters more than keeping the document portable.

Finding slow components with profile()

profile() renders a document without writing it and reports where the time went: your React components, reading the tree, images and fonts, and each engine phase (layout, text, paint, write). It also gives each page's time and the peak memory. In Node it samples the CPU and groups the time by package and by function.

import { profile, formatProfile } from '@axonpdf/react';

const report = await profile(<Invoice data={data} />);
console.log(formatProfile(report));

Running the Node benchmark yourself

From a clone of the axonpdf repository, with poppler and qpdf installed:

cd bench && npm ci && cd ..
node bench/run.mjs                                   # every engine, 10 to 5000 pages
node bench/run.mjs --engines axonpdf --sizes 1000    # one run

Each run adds a row to bench/RESULTS.md.

On this page