oxc-project / oxc-project/backlog
Maintain cache coherence in transformer
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Boshen mentioned this is meeting yesterday. Oxc's AST has the advantage of storing all nodes in arena in traversal order (broadly speaking - Vec content will jump around when Vecs grow (#35)).
The transformer throws the distribution of AST nodes in memory into disarray because new nodes it inserts are stored at the end (bottom) of the arena, far away from the AST data for surrounding nodes.
I do not think this problem is solvable in general. However, we could ameliorate it somewhat for JSX and TS syntax where it's predictable how it's going to be transformed. For example:
<Foo />
is transformed to:
_jsx(Foo, {})
We could make it so when parser writes a JSXElement into arena, it leaves sufficient free bytes after it so that the JSXElement + unused bytes is enough bytes to store a CallExpression, Vec<Argument>, ObjectExpression, and Vec<ObjectPropertyKind>. The transformer could use that space to replace the JSXElement in place in the arena.
There are 3 downsides:
- Hard to calculate how much space is needed ahead of time (depends on whether classic/automatic mode JSX transform).
- Risk of overwriting other AST nodes (which would be UB).
- Currently we know that a
*mut Whateverpointing into arena always points to valid data until the arena isreset(), because even if the node is removed from AST, the old node still sits in same place in the arena. Replacing nodes in place would break this invariant. It may make unsafe code e.g.Traverseharder to make sound.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or concrete entry points are named. Start by tracing the parser's AST arena, JSX and TypeScript transformer paths, and the Traverse raw-pointer invariant; define completion as a measured coherence improvement that does not introduce arena overwrites or invalidate pointer safety.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100