-
-
Notifications
You must be signed in to change notification settings - Fork 501
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
feat(ast): add AstNode
trait and provide access to AstNodeId
#2861
feat(ast): add AstNode
trait and provide access to AstNodeId
#2861
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
AstNode
trait and its derive macro.AstNode
trait and provide access to AstNodeId
CodSpeed Performance ReportMerging #2861 will degrade performances by 3.05%Comparing Summary
Benchmarks breakdown
|
1a7cb08
to
5f60ac7
Compare
ffd871f
to
2d2f8f4
Compare
crates/oxc_ast/src/ast/jsx.rs
Outdated
@@ -24,10 +26,13 @@ pub struct JSXElement<'a> { | |||
pub opening_element: Box<'a, JSXOpeningElement<'a>>, | |||
pub closing_element: Option<Box<'a, JSXClosingElement<'a>>>, | |||
pub children: Vec<'a, JSXChild<'a>>, | |||
|
|||
#[cfg_attr(feature = "serialize", serde(skip))] | |||
pub(crate) ast_node_id: AstNodeIdContainer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Boshen I like the idea of keeping the raw ast node IDs private to the crate, But it would mean that we have to either add new
functions for a bunch of types or add missing types to ast_builder so we can use that in all cases instead of constructing with Type { ... }
syntax. With ast_node_id private only enum types can be initialized directly.
Should I go for it or make the field public? The public field is a bit less encapsulated and results in a more verbose construction since you always need to set the field to default but reduces the dependency on ast builder, Do we want our types to even be initialized without a builder? Or do we desire to keep all allocations in a singular point? The ladder by default means that moving constructions to the builder is a plus but I can't say the same thing for the first one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move all allocations to the builder we might want to make them inline
as well to reduce the jumps while constructing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make it public for now so it won't stop my progress, But it is up for debate if anyone wants to pitch in on how we would approach it. I can address it in an upcoming PR.
In my view std::mem::size_of::<Cell<Option<usize>>>() == 16
std::mem::size_of::<Cell<Option<NonZeroUsize>>>() == 8 This would likely reduce the performance reduction visible on this PR at present. You'd just need to initialize Also, in my view |
Let's keep this branch live, even though PR is closed. We may want to come back to this later. |
closes #2818