Replies: 1 comment 1 reply
-
After spending a few days fighting to learn Rust, I've narrowed the perf difference slightly. The approach I took was to pass a Buffer/UInt8Array in to WASM rather than a string, to avoid a utf16->utf8 conversion getting to a Rust string. Then, instead of creating an AST in Rust (with a bunch of allocation, followed by a bunch of utf8->utf16 conversions for each string on the way out, causing more allocations), I create a Vec, which has TokenType, startByte, endByte triplets for each interesting parse token found. There's utf8->utf16 decodes that happen per field at that point. I also tried u16's instead of u32's, to see if that mattered. The benchmark results:
Notes:
Conclusions:
|
Beta Was this translation helpful? Give feedback.
-
There's a great rust-based parser that can be turned into WASM at one-ini. The hope is that this could be one parser that most of the editconfig cores could use, so that there would be consistency.
There's also a parser I wrote in Peggy that does roughly the same thing, but handles comments in a few more places -- even though that's somewhat-discouraged by the spec. The extra comment handling could be removed, for a slight performance win.
I wrote a simple benchmark using Kelonio that parses each of the test input files, turns them into the expected results from
parseString
. I repeated this 10k times for each parser. Here are the results:As you can see,
one-ini
is much more consistent (I assume because there's a lot less GC in that loop), but the Peggy parser is noticeably faster. I think some part of that is marshaling and parsing across the WASM boundary, and there is a small part that is the required remapping logic.Sizes of all the files included in the distro:
Both parsers parse all of the tests in the current test suite.
If other editorconfig cores start to use one-ini, the benefits of consistency might be worth a few more bytes, and a somewhat-slower parse.
Does anyone have an opinion?
Beta Was this translation helpful? Give feedback.
All reactions