LibWeb/CSS: Port the CSS Tokenizer to Rust#8926
LibWeb/CSS: Port the CSS Tokenizer to Rust#8926AtkinsSJ wants to merge 3 commits intoLadybirdBrowser:masterfrom
Conversation
test-css-tokenizer is updated to run both the C++ and Rust tokenizers and compare their output, to ensure they behave identically. The Parser still uses the C++ Tokenizer. The LibWeb crate, FFI layer etc are all based on the existing ones for other libraries. This is a direct AI translation to get us started, and not idiomatic Rust. Future work can be done to make it more sensible.
|
Have you verified speed and/or memory usage just to ensure there is no significant regression? |
|
Good point. Here's a hyperfine run on my MacBook Pro, running on the UA stylesheet which is >2000 lines. After doing this a few times, the Rust one is consistently 2-3% slower. So, not significantly different, though it is a regression. I'll keep an eye on it when working on it later. I can't seem to get a memory reading, do you have any tips for that? |
|
|
Thanks, I couldn't get that to work before but turns out macos has a gnu-time package, so it's all good now. 😅 C++: Rust: So that's... 11% more memory used by my reckoning? |
This is an AI translation of the CSS Tokenizer.
test-css-tokenizerhas been updated to run both Tokenizers and compare the output to make sure it's identical. There isn't yet any support for using it inside LibWeb.I am very much a Rust novice, and this is very much written by AI. (Codex to be specific.) I have reviewed it myself and as far as I can tell it's correct, and the tests suggest that too, but as I said I am not familiar with Rust. I'm sure the module structure etc is not exactly what it should be.
The code itself is not idiomatic but that's to be expected as a direct translation, and improving that is a future task.
In particular, feedback on the CMake and the FFI parts could use some scrutiny by someone who understands those better.