August 2026 (3)

2026-08-28

mORMot 2 HTTP Server: Memory Efficiency and Thread Smoothing

High-performance HTTP servers are often benchmarked primarily by their peak requests per second. For a REST server, however, peak throughput is only part of the story. A server also needs to remain responsive when requests have very different execution times: some may complete in a few microseconds, while others may spend milliseconds waiting for a database, a remote service, or some other slow operation.

The mORMot 2 asynchronous HTTP server was one of the fastest in the TFB benchmark. But it was designed as a scalable REST server. Our project has recently received two related improvements in this area: a closer look at its memory allocation behavior, and a refined thread smoothing mechanism for waking worker threads on POSIX systems.

Continue reading

2026-08-12

A New Native i18n Layer for mORMot 2

Internationalization (aka i18n) is now part of the mORMot 2 core with the new mormot.core.i18n unit, introduced by PR #510 - and deeply rewritten and completed, as always. The goal is not to create yet another translation format, but to provide a small, fast and framework-native i18n layer for both Delphi and Free Pascal.

The basic principle is deliberately simple: the original English text is the translation key. For example, "Hello" can be translated to "Bonjour". If a translation is missing, the original text remains available as the natural fallback. This keeps application code readable and makes the translation tables straightforward to maintain.

Continue reading

2026-08-07

A 2 GB/s XML Parser for Delphi and Free Pascal: SAX, Streaming and DOM Without the Usual Trade-offs

XML may no longer be fashionable, but it is still everywhere.

Scientific datasets, configuration files, industry standards, legacy systems, government data, document formats and countless integration interfaces continue to produce XML. And when XML documents become large, the choice of parser can make a surprisingly large difference.

For mORMot 2, we have recently written a new XML parser, TXmlParser, with a slightly different goal from the traditional XML libraries found in the Delphi and Free Pascal ecosystems. It started from an AI-driven pull request from zen010101, then it was fully rewritten by hand for performance and enhanced to support several API modes.

Instead of choosing between a low-level SAX parser and a convenient DOM parser, the same parser provides several levels of access:

  • a zero-allocation SAX/pull API;
  • a streaming/navigation API for selecting only the parts of the document that matter;
  • a hybrid SAX/DOM API, where selected subtrees can be materialized as TDocVariantData;
  • and a full XML-to-TDocVariant DOM representation, when that is what the application actually needs.

The interesting part is that the performance remains very high at all these levels.

Using the 24 MB nasa.xml reference document from the University of Washington XML repository, the raw parser reaches about 2.1 GB/s, while the full DOM conversion reaches about 424 MB/s. Selective streaming reaches about 1.6 GB/s, and once the DOM exists, traversing it through the new TDocVariantData.Product() enumerator reaches about 7 GB/s.

There is also an interesting memory optimization: enabling dvoInternNames reduces the complete DOM footprint from approximately 60 MB to 40 MB, with essentially no performance penalty.

The complete benchmark is shown below.

Continue reading