-
-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Atom
safe and faster
#2295
Comments
Can I tackle this? I already have a WIP which steals a lot of the efficient code of But now that the memory leak is solved, perhaps it's a little less urgent? |
I want to enable as many good engineering practices as possible so I was eager to make the code memory-leak free so we can turn on miri. It wasn't about impatience 😅 |
Sorry, that wasn't criticism or a barbed comment. It was more of an apology that I said I'd do it, and then I haven't. I started hacking on the lexer just to gain familiarity with the codebase, but have ended up going down a performance-chasing rabbit hole! It's too much fun. Anyway, I think I'm getting towards the end of that work now. #2288 is the major building block for lexer optimization, and I should have the PR which builds on it to speed up lexing identifiers (the one that gives the 10% parser speed up) ready in a few days. So should be able to turn my attention to That sound OK to you? |
I can't wait! But take your time and enjoy the fun! |
Instead of exposing a single
For maximum performance, The |
This is really nice - nice combination of efficiency and usability. Just to check a couple of things:
I'm unclear how
We could probably squeeze it down smaller using pointer compression, but:
Or have I misunderstood, and you have something else in mind? |
Yes.
16 bytes would be even better! If you can shrink it down :-) |
Alright, we are going to solve this problem in a few steps:
|
Sounds like a plan! Do we need Advantage of that would be that for strings under 16 bytes, converting from But if |
Yes, this is totally possible. Same size as |
Part of #2295 This PR splits the `Atom` type into `Atom<'a>` and `CompactString`. All the AST node strings now use `Atom<'a>` instead of `Atom` to signify it belongs to the arena. It is now up to the user to select which form of the string to use. This PR essentially removes the really unsafe code https://github.com/oxc-project/oxc/blob/93742f89e91bc7c45491b6d2b49a134fa65f2b5c/crates/oxc_span/src/atom.rs#L98-L107 which can lead to ![image](https://github.com/oxc-project/oxc/assets/1430279/8c513c4f-19b0-4b63-b61c-e07c187c95b5)
Continue on oxc-project/backlog#46 |
…oject#2497) Part of oxc-project#2295 This PR splits the `Atom` type into `Atom<'a>` and `CompactString`. All the AST node strings now use `Atom<'a>` instead of `Atom` to signify it belongs to the arena. It is now up to the user to select which form of the string to use. This PR essentially removes the really unsafe code https://github.com/oxc-project/oxc/blob/93742f89e91bc7c45491b6d2b49a134fa65f2b5c/crates/oxc_span/src/atom.rs#L98-L107 which can lead to ![image](https://github.com/oxc-project/oxc/assets/1430279/8c513c4f-19b0-4b63-b61c-e07c187c95b5)
Atom
had a memory leak which is not desirable: #1803I removed the memory and miri test to the parser: #2294
The change introduced some performance regressions and a unsafe
oxc/crates/oxc_span/src/atom.rs
Lines 103 to 104 in 6002560
The next goal is to remove this unsafe.
The text was updated successfully, but these errors were encountered: