Project

General

Profile

Bug #12168

Reduce FWD server heap: read DMO @Property without reflection, share proxy Method objects

Added by Artur Școlnic 10 days ago. Updated 7 days ago.

Status:
Test
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

Related issues

Related to Base Language - Feature #6407: name_map.xml improvements Test
Related to Runtime Infrastructure - Bug #12161: Live memory allocation optimizations. Review
Related to Base Language - Feature #12222: Remove name_map.xml by using annotations Review

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 in DmoMeta.getPropertiesList() and copies the values into orm.Property, but the cached object can never be freed, because the Method objects held by proxies and orm.Property keep it reachable.
  • Duplicated Method objects (23–74 MB). ProxyFactory.gatherMethods() called getDeclaredMethods() / getMethods() for every generated proxy class. Each call returns fresh copies, so each proxy kept its own copy of ~600 BufferImpl methods (530k–842k copies per server).

Changes

  • New DmoAnnotationReader reads @Property values 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 DynamicTablesHelper and SchemaCheck pass the generated class bytes through a new DmoMetadataManager.registerDmo(..., Map<String, byte[]>) overload.
  • ProxyFactory caches each class's method arrays (ClassValue), so all proxy classes share the same Method instances.

Result (multi tenant app, same test, before/after)

  • Live heap: 1,375 MB → 1,113 MB (−263 MB, −19%).
  • @Property annotation objects: 79,573 → 0 (−187 MB).
  • Method objects: 1.74 M → 1.04 M (−62 MB); BufferImpl copies: 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

#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

Also available in: Atom PDF