Skip to content

Switch KDL parsers (from kdl crate to kdlite)#362

Open
DorianNiemiecSVRJS wants to merge 4 commits intodevelop-2.xfrom
feature/kdlite-parser
Open

Switch KDL parsers (from kdl crate to kdlite)#362
DorianNiemiecSVRJS wants to merge 4 commits intodevelop-2.xfrom
feature/kdlite-parser

Conversation

@DorianNiemiecSVRJS
Copy link
Member

This pull request would replace kdl crate with kdlite crate. It also removes the miette crate dependency.

The kdlite crate is a small, streaming KDL parser for Rust, which is based on just-kdl crate.

Motivation

From kdlite Rust crate documentation:

The official Rust implementation is designed to support editing of kdl files. While this is normally useful, my main use of KDL is to just parse the values into some internal data structure (configuration, document trees, etc.) where formatting information is entirely redundant and just wasteful of parsing time and memory.

Performance tests

Setup

Ferron is started with the KDL-format configuration generated using this script (that can be run on Node.js):

for (let i = 1; i < 513; i++) {
  for (let j = 2; j < 514; j++) {
    console.log(`example${i}.com:${j} {\n  root "/tmp/example${i}.com_${j}"\n}\n`);
  }
}

This script can be then run like this (on GNU/Linux):

node loadconf.js > /tmp/ferron.kdl # Replace "loadconf.js" with the script filename

Ferron with kdl crate:

❯ time ./target/release-old/ferron -c /tmp/ferron.kdl
Error while running a server: Cannot listen to HTTP port: Permission denied (os error 13)
./target/release-old/ferron -c /tmp/ferron.kdl  3,22s user 0,12s system 96% cpu 3,461 total

Ferron with kdlite crate:

❯ time ./target/release/ferron -c /tmp/ferron.kdl
Error while running a server: Cannot listen to HTTP port: Permission denied (os error 13)
./target/release/ferron -c /tmp/ferron.kdl  1,19s user 0,06s system 92% cpu 1,351 total

Comparsion

Ferron with kdlite crate took only 1.351s for processing the server configuration, while Ferron with kdl crate took 3.461s for processing the same configuration.

@DorianNiemiecSVRJS DorianNiemiecSVRJS added the rust Pull requests that update rust code label Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant