Opened 6 weeks ago

#5856 assigned enhancement

Reduce the number of created CValues at runtime

Reported by: tgutzmann Owned by: tgutzmann
Priority: major Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:

Description

Compiling
Modelica.Electrical.Spice3.Examples.Spice3BenchmarkFourBitBinaryAdder
currently creates more than 6.000.000 CValues of different kinds. And that's only through the constructors, not including those from clone()

A few simple things can be done to improve this:

  • The worst thing is that InstNamedAccess.ceval() initializes the result with "unknownValue()" which is always re-assigned. That's about 3.150.000 unnecessary object creations
  • CValueBoolean, CValueReal and CValueInteger should cache most commonly used objects; use a valueOf() function and constructors should be private.

-- for CValueBoolean, all object creations (about 490000 !) can be removed
-- for CValueReal, caching 0.0 (not -0.0 !) should go from 1.360.000 to about 400.000.
-- for CValueInteger, caching 0 should go from about 570.000 to about 120.000

Additionally, cloning immutable object should return just the immutable objects.

Change History (0)

Note: See TracTickets for help on using tickets.