bhollis-dbx opened a new pull request, #58865:
URL: https://github.com/apache/spark/pull/58865

   ### What changes were proposed in this pull request?
   
   Replace five per-`TreeNode` `BestEffortLazyVal` instances with nullable 
volatile cache fields and lock-free lazy accessors. The affected properties are 
`treePatternBits`, `containsChild`, `height`, `hashCode`, and `allChildren`.
   
   Add a regression test for allocation when constructing unused `Literal` 
expressions.
   
   ### Why are the changes needed?
   
   Every tree node currently allocates five memoizers and their initializer 
closures even when their properties are never read. Catalyst creates large 
numbers of expression and plan nodes, making this unused cache state expensive.
   
   On the measured JVM, constructing an unused `Literal` falls from 280 to 81 
allocated bytes, saving 199 bytes (71%) per node. The new accessors preserve 
lock-free concurrent initialization, single-result publication, origin 
behavior, and retry after computation failure.
   
   This is kind of a messy optimization, but it may be worth it given the 
memory savings across all TreeNodes. It's a judgement call whether that win is 
worth the harder-to-read code.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added an unused-`Literal` construction allocation test and ran:
   
   `build/sbt 'catalyst/testOnly *TreeNodeSuite'`
   
   All 37 tests passed.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Codex (GPT-5)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to