Expand description
Small streaming KDL v2.0.0 parser
Designed for reasonable performance and memory efficiency, at the expense (or benefit, depending on use) of not storing formatting information
§Why?
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.
Additionally, this implementation has a few other benefits:
- Full v2.0.0 compliance
- Significantly fewer dependencies!
§Benchmarks
On my personal laptop, on low power setting:
// in release mode
bench "html-standard-compact.kdl" {
JustKdlDom {
time "688.9548ms"
memory new=217_494_981 free=28_488_457 net=189_006_524
}
Kdl {
time "13.228400752s"
memory new=5_219_542_533 free=4_305_774_657 net=913_767_876
}
}
bench "html-standard.kdl" {
JustKdlDom {
time "628.389088ms"
memory new=357_151_222 free=35_738_264 net=321_412_958
}
Kdl {
time "18.194044124s"
memory new=8_146_781_320 free=6_584_885_611 net=1_561_895_709
}
}
// in debug mode
bench "html-standard-compact.kdl" {
JustKdlDom {
time "4.169828469s"
memory new=217_494_981 free=28_488_457 net=189_006_524
}
Kdl {
time "149.249652517s"
memory new=5_219_542_533 free=4_305_774_657 net=913_767_876
}
}
bench "html-standard.kdl" {
JustKdlDom {
time "5.756129305s"
memory new=357_151_222 free=35_738_264 net=321_412_958
}
Kdl {
time "211.812757636s"
memory new=8_146_781_320 free=6_584_885_611 net=1_561_895_709
}
}In summary:
- 19-36 times faster (on average, will likely be less in practice)
- significantly fewer temporary allocations
- fewer output allocations (even with cleared formatting!)