Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Performance Characteristics

The Focus of mdka

The Rust ecosystem offers a variety of excellent HTML-to-Markdown converters. Many of these projects prioritize feature-richness, complex edge-case handling, or high extensibility.

mdka takes a different approach. Our mission is to provide a “minimalist, lightweight, and memory-efficient” converter, specifically optimized for resource-constrained environments or high-concurrency tasks where overhead must be kept to an absolute minimum.

The benchmarks presented here are not intended to rank libraries or declare a “winner.” Instead, they serve as internal metrics to verify whether mdka is successfully meeting its own design goals. We believe in choosing the right tool for the specific job, and we encourage developers to explore the diverse range of libraries available in the ecosystem to find the one that best fits their needs.

The Evolution: v1 to v2

With the release of v2, mdka underwent a complete architectural overhaul. We moved away from the original implementation to a ground-up rewrite focused on:

  • Stack-Safe Traversal: Implementing a non-recursive Deep First Search (DFS) to prevent stack overflow even with deeply nested HTML.
  • Optimized Memory Allocation: Reducing unnecessary clones and leveraging Rust’s ownership model to minimize peak memory usage.
  • Streamlined Processing: Simplifying the conversion logic to achieve a predictable and lightweight execution path.

This rewrite resulted in a dramatic performance leap and a significantly reduced memory footprint compared to our previous version.

Benchmark Results (2026-04-15)

The following data demonstrates how the v2 architecture has improved our efficiency and how it aligns with our goal of “reasonable speed with minimal resource consumption.”

The figures below are wall-clock medians from Criterion. The log also records outliers for each run, so small differences should be read with some caution.

Conditions

All libraries were benchmarked under the same conditions:
Linux x86_64 6.19, Rust 1.94.1, Criterion 0.8, 28 logical cores, 3 s warm-up, and 3 s measurement.

Libraries Under Test

LibraryVersionHTML parserApproach
mdka2.0.0scraper (html5ever)Full DOM tree; non-recursive DFS
mdka_v11.6.9html5everFull DOM tree; older implementation
html2md0.2.15html5everDOM-based converter
fast_html2md0.0.61lol_htmlStreaming rewriter
htmd0.5.4html5everDOM-based converter
html_to_markdown_rs3.1.0html5everDOM-based converter
html2text0.16.7html5everText-oriented converter
dom_smoothie0.17.0dom_query (html5ever)DOM-oriented converter

These libraries do not share the same design and do have different approach and goals.

Conversion Speed

Datasetmdka v2mdka v1html2mdfast_html2mdhtmdhtml_to_markdown_rshtml2textdom_smoothie
small131.52 µs131.66 µs132.21 µs79.50 µs90.47 µs107.82 µs350.92 µs317.37 µs
medium1.3040 ms2.2866 ms1.5266 ms887.59 µs1.0562 ms1.1660 ms3.3999 ms2.7643 ms
large12.336 ms75.751 ms12.455 ms7.0399 ms7.7896 ms9.6825 ms29.854 ms26.062 ms
deep_nest32.620 ms373.10 ms36.834 ms5.9868 ms72.481 ms96.744 ms30.903 ms29.408 ms
flat5.6253 ms24.817 ms6.7911 ms4.2114 ms5.5321 ms4.6975 ms14.023 ms29.408 ms
malformed31.712 µs40.178 µs71.778 µs52.948 µs62.302 µs41.109 µs96.822 µs5.6401 ms

mdka v2 is clearly ahead of mdka v1 in this run. The gain is small on the smallest input, but it becomes much more visible as the input gets larger or structurally harder: around 1.75× faster on medium, 6.1× on large, 11.4× on deep_nest, and 4.4× on flat. On malformed input, v2 is also faster than v1 and the fastest.

Memory Allocation

Datasetmdka v2mdka_v1html2mdfast_html2mdhtmdhtml_to_markdown_rshtml2textdom_smoothie
small113.5 KB240 KB231 KB154 KB93.6 KB232.5 KB764.5 KB325.4 KB
medium984.6 KB2.03 MB1.95 MB1.52 MB1.01 MB1.95 MB8.50 MB2.85 MB
large8.00 MB17.0 MB16.76 MB11.98 MB7.85 MB16.76 MB74.89 MB23.08 MB
deep_nest3.00 MB4.71 MB2.55 MB6.85 MB1.96 MB2.55 MB18.48 MB
flat3.93 MB7.90 MB7.87 MB7.46 MB4.84 MB7.87 MB40.28 MB35.47 MB
malformed44.7 KB91.6 KB71.4 KB145 KB62.3 KB71.4 KB464.4 KB1.63 MB

In this run, mdka v2 uses less heap than v1.

Summary

As shown in the results, the transition to v2 has allowed us to achieve our objectives of being lightweight and memory-efficient while maintaining competitive speed.

We recognize that other libraries may offer more features or different trade-offs that make them better suited for certain applications. mdka aims to be the best choice for those who prioritize a simple, “Unix-style” tool that does one thing—conversion—with the smallest possible footprint.