jdaugherty opened a new pull request, #16747:
URL: https://github.com/apache/grails-core/pull/16747

   `AstUtils.isDomainClass(ClassNode)` was `@Memoized`. Groovy's default memo 
is an unbounded cache keyed by argument equality, and `ClassNode` equality is 
the class name, so every node ever asked about was pinned for the life of the 
JVM, and with it the node's module, the compile unit and the class loader of 
its compilation. In a forked Groovy compiler that Gradle reuses for a project's 
main and test compiles, that is the whole AST of the previous compile.
   
   Measured on 9.0.x after the grails-datamapping-core test compile: the 
compiler fork still held 194,420 `ClassNode`s and 154 `ModuleNode`s, 222 MB 
after a full collection, when the next compile started; with this change the 
same point holds one `ModuleNode` and 76 MB. The MongoDB core test compile of 
#16631 then ran out of its 2 GB on CI, which is where this was found.
   
   The verdict now lives as node metadata on the node's `redirect()`, the way 
`AstPropertyResolveUtils` already keeps its property cache, so it is collected 
with the node, and two same-named nodes from different compilations, such as 
test fixtures compiled from strings, each get their own answer; #16653 had 
added `isDomainClassUncached` on 9.0.x to sidestep that collision for the id 
and version placement, and that uncached check now backs the cached one here as 
well. The memo dates from GORM itself (ee14a969f9, 2015) and came in with the 
GORM integration (a58aa145cf); it is the same on every branch from 7.0.x up, so 
this is the oldest branch and merges up. The same change rides in #16631 as its 
own commit until this one reaches 9.0.x.
   
   Verified: `grails-datastore-core` and `grails-datamapping-core` suites and 
`codeStyle` on 7.0.x; the new spec in `AstUtilsSpec` covers the same-name case.
   


-- 
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]

Reply via email to