Scanning HTML at Tens of Gigabytes per Second on ARM Processors
Daniel Lemire · 2025
Read Scanning HTML at Tens of Gigabytes per Second on ARM Processors by Daniel Lemire (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2503-01662.txt.
Introduction
Daniel Lemire shows, in a 2025 paper, how to scan HTML at tens of gigabytes per second on ARM processors. Browsers spend real time just finding the meaningful characters in a page's markup. Modern chips can chew sixteen or more bytes per instruction, a trick called SIMD, and recent parsers for formats like JSON ride it hard. HTML scanning uses a cousin technique, vectorized classification, to spot target characters in bulk.
Lemire reviews how those classifiers work and pits them against a faster alternative of his own. On recent ARM hardware the new approach scans about twenty times faster than traditional byte-by-byte methods. The paper is a craftsman's note: short, measured, and aimed at the engineers who build the parsing layer under every web page. Its moral is that the web's oldest format still has speed left in it.
Catalog record
| CREATOR | Daniel Lemire |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 40 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2503-01662
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Scanning HTML at Tens of Gigabytes per Second on ARM Processors Daniel Lemire Abstract Modern processors have instructions to process 16 bytes or more at once. These instructions are called SIMD, for single instruction, multiple data. Recent advances have leveraged SIMD instructions to accelerate parsing of common Internet formats such as JSON and base64. The two major Web browser engines (WebKit and Blink) have adopted SIMD algorithms for parsing HTML on 64-bit ARM processors. During HTML parsing, they quickly identify specific characters with a strategy called vectorized classification . We review their techniques and compare them with a faster alternative. We measure a 20-fold performance improvement in HTML scanning compared to traditional methods on recent ARM processors. Our findings highlight the potential of SIMD-based algorithms for optimizing Web browser performance. \corraddress Daniel Lemire, Data Science Research Center, Université du Québec (TELUQ), Montreal, Quebec, H2S 3L5, Canada \corremail [email protected] \fundinginfo Natural Sciences and Engineering Research Council of Canada, Grant Number: RGPIN-2024-03787 keywords Text Parsing, Vectorization, Web Performance 1 Introduction SIMD (Single Instruction, Multiple Data) instructions allow operations to be performed on multiple words simultaneously. For example, we can compare sixteen bytes with sixteen other bytes with one instruction. Commodity processors (e.g., Intel, AMD, ARM, POWER) have supported single-instruction-multiple-data (SIMD) instructions for decades. Recent ARM processors have four instruction units capable of executing SIMD instructions [ 1 ] and thirty-two SIMD registers. Nejati and Balasubramanian found that computational tasks such as HTTP parsing may account for for over 60% of the page load latency on mobile browsers [ 2 ] . Yet, until recently, mainstream Web browsers did not use explicitly SIMD instructions for critical tasks such as parsing HTML pages. Most browsers today use either the WebKit or Blink Web engines. WebKit is developed primarily by Apple for their Safari browser. WebKit is derived from KHTML, a Web engine developed for Linux and BSD by the KDE project. In turn, Google based their Blink engine on WebKit. It is now part of Google Chrome, Brave and Microsoft Edge. See Table 1 . Blink and WebKit share many similarities both because of their common origin, but also because they tend to emulate each other. For example, the WebKit engine adopted a fast path for HTML parsing called HTMLFastPathParser first developed for Blink. This fast HTML parser supports only a fixed set of common tags: it is used when JavaScript assigns HTML content to an element. In May 2024, WebKit adopted SIMDe [ 3 ] , a framework to help support SIMD instructions across various systems. SIMDe was quickly used to accelerate HTML parsing (i.e., the HTMLFastPathParser function). 1 1 1 https://github.com/WebKit/WebKit/pull/28251 Maybe coincidentally, again in May 2024, another major Web engine (Blink) adopted Highway [ 4 ] , a software framework similar to SIMDe---along with a strikingly similar optimization to the HTML parsing. 2 2 2 https://chromium-review.googlesource.com/c/chromium/src/+/5538407 The net result is that—within a few weeks—nearly the same SIMD-based optimization was adopted by the two main Web engines. The Google engineers reported a 2% performance boost on the jQuery component of the Speedometer 3 test [ 5 ] following this optimization. We write Web pages using the Hypertext Markup Language (HTML) [ 6 ] . Thus HTML is probably one of the most important document formats in software history. HTML is a text format most commonly encoded as UTF-8—a superset of ASCII. A fundamental component of HTML is the element. Typically, an element begins with a starting tag (e.g., <name> ) and ends with a closing tag (e.g., </name> ). The ampersand ‘ & ’ represents HTML entities : special sequences that are typically used to represent special characters. For example, ‘ < ’ represents the less-than character, ‘ > ’ represents the greater-than character, ‘ " ’ represents the quote. Web engine vendor parent time KHTML KDE khtmlw library 1998–… WebKit Apple KHTML 2005–… Blink Google WebKit 2013–… Table 1 : History of Web Engines Both major Web engines (WebKit, Blink) rely on the same fundamental step when parsing HTML as part of the HTML tokenization. They scan the text input for the less-than character ‘ < ’ which marks the beginning of a tag. Furthermore, three other characters must be detected as they trigger special code paths: • Whenever the carriage return character is found, browsers normalize the newlines [ 7 ] . Specifically, all sequences of the carriage return character followed by the line feed character (‘ \r\n ’) are replaced by line feed character (‘ \n ’), and all remaining carriage return characters are replaced by a line feed character. • The ampersand character must be detected as it may indicate the presence of an entity which must be replaced. • We must also detect null characters (‘ \0 ’) as they trigger an error and a replacement. In practice, we expect the software to jump from one less-than character ‘ < ’ to another, as they are most common. Fig. 1 illustrates how Web engines solve this problem with conventional C code. ⬇ // pos is a pointer inside the document while ( pos != end && * pos != '<' ) { if (* pos_ == '&' || * pos_ == '\r' || * pos == '\0' ) { return SPECIAL ; // special handling } ++ pos ; } Figure 1 : C code to move a pointer to the next less-than character More generally, programmers often write code to scan a string of characters and identify some classes of characters. For example, we might want to find all spaces, and numbers and so forth. The conventional approach is to load the characters one by one and to identify them using comparisons, as in Fig. 1 . It is a sufficiently common task that standard libraries provide support for such tasks. For example, the C++ standard library offers the std::string::find_first_of function. In C#, the standard library has a powerful SearchValues class. Thus, even though the problem solved by the engineers working on major Web engines is specific, it is also an instance of a generic problem of wide interest. 2 SIMD Algorithm To scan text faster, we might want to load blocks of consecutive characters and classify them at once. We refer to the general approach where one classifies characters using SIMD instructions as vectorized classification [ 8 ] . It comes in different forms. For example, a single SIMD comparison may be needed: e.g., if we need to compare a single character with every character in the block. In more complex cases, a sequence of instructions may be required: e.g., when validating Unicode strings [ 9 , 10 ] or parsing URLs [ 11 ] . We might have conditions, e.g., a character type must be followed by another character. At a high level, the vectorized classification problem recently solved by the Web engines WebKit and Blink is described by Algorithm 1 . We repeatedly load blocks of k consecutive characters in a vector, and check whether one of these characters is in the desired set—where k might be 16, 32, 64, …. If not, we advance by k characters and load a new block of k characters. See § 4.1 and § 4.2 for