Bug #12168
Reduce FWD server heap: read DMO @Property without reflection, share proxy Method objects
100%
Related issues
History
#1 Updated by Artur Școlnic 10 days ago
- Status changed from New to WIP
- Assignee set to Artur Școlnic
Motivation
Heap dumps of three FWD servers (different appps) after 15 minutes of testing showed two fixed-cost items common to all of them:
- *
Property annotation objects (100–190 MB).* The JDK parses each DMO field's@Property@ annotation into an object that stores all 38 members, defaults included (~2.3 KB per field), and caches it for the life of the class. FWD reads it once inDmoMeta.getPropertiesList()and copies the values intoorm.Property, but the cached object can never be freed, because theMethodobjects held by proxies andorm.Propertykeep it reachable. - Duplicated Method objects (23–74 MB).
ProxyFactory.gatherMethods()calledgetDeclaredMethods()/getMethods()for every generated proxy class. Each call returns fresh copies, so each proxy kept its own copy of ~600BufferImplmethods (530k–842k copies per server).
Changes
- New
DmoAnnotationReaderreads@Propertyvalues directly from the class file with ASM, so the JDK never creates or caches the annotation objects. If no class file is available, it falls back to reflection. - Dynamic temp-tables only exist in memory, so
DynamicTablesHelperandSchemaCheckpass the generated class bytes through a newDmoMetadataManager.registerDmo(..., Map<String, byte[]>)overload. ProxyFactorycaches each class's method arrays (ClassValue), so all proxy classes share the sameMethodinstances.
Result (multi tenant app, same test, before/after)
- Live heap: 1,375 MB → 1,113 MB (−263 MB, −19%).
@Propertyannotation objects: 79,573 → 0 (−187 MB).Methodobjects: 1.74 M → 1.04 M (−62 MB);BufferImplcopies: 530,901 → 401.
On a large production server the saving stays roughly the same in absolute terms: a fixed 300-600Mb rather than a percentage of the heap.
#2 Updated by Artur Școlnic 10 days ago
- Status changed from WIP to Review
- % Done changed from 0 to 100
- reviewer Constantin Asofiei added
Constantin, please review 12168a.
#3 Updated by Constantin Asofiei 10 days ago
Please commit DmoAnnotationReader
Can you check SourceNameMapper, what is the heap required for reading all the legacy annotations from the converted source code?
#4 Updated by Artur Școlnic 10 days ago
Constantin Asofiei wrote:
Please commit DmoAnnotationReader
Done, sorry I missed it...
Can you check SourceNameMapper, what is the heap required for reading all the legacy annotations from the converted source code?
Reading the legacy annotations through reflection costs about 2.1 KB per @LegacySignature and 0.85 KB per @LegacyParameter.
In the application dumps I used this amounts to 30-40Mb, worth fixing.
#5 Updated by Constantin Asofiei 10 days ago
Artur Școlnic wrote:
Reading the legacy annotations through reflection costs about 2.1 KB per @LegacySignature and 0.85 KB per @LegacyParameter.
In the application dumps I used this amounts to 30-40Mb, worth fixing.
How many java.lang.Class objects were there loaded? We have apps with 10k's of converted files.
I think is worth it, this is 'read and forget' code which is not useful one processed, so no need to keep it cached in the JVM. Consider making DmoAnnotationReader more generic to handle any kind of annotation.
#6 Updated by Artur Școlnic 10 days ago
- Status changed from Review to WIP
Constantin Asofiei wrote:
How many java.lang.Class objects were there loaded?
70-90k, depending on the app.
I think is worth it, this is 'read and forget' code which is not useful one processed, so no need to keep it cached in the JVM. Consider making DmoAnnotationReader more generic to handle any kind of annotation.
Will do.
#7 Updated by Greg Shah 10 days ago
- Related to Feature #6407: name_map.xml improvements added
#8 Updated by Artur Școlnic 10 days ago
- Status changed from WIP to Review
Constantin, please review rev 12168a/16851.
#9 Updated by Șerban Bursuc 10 days ago
- Related to Bug #12161: Live memory allocation optimizations. added
#10 Updated by Constantin Asofiei 10 days ago
- Status changed from Review to Internal Test
Artur Școlnic wrote:
Constantin, please review rev 12168a/16851.
Thanks, lets get this tested.
#11 Updated by Artur Școlnic 7 days ago
Multi tenant app, large gui app unit tests, chui regression and etf testing passed. Can we merge?
#12 Updated by Constantin Asofiei 7 days ago
- Status changed from Internal Test to Merge Pending
Yes, go ahead now.
#13 Updated by Artur Școlnic 7 days ago
- Status changed from Merge Pending to Test
12168a was merged to trunk/16850.
#14 Updated by Dănuț Filimon 4 days ago
- Related to Feature #12222: Remove name_map.xml by using annotations added