Opened 16 years ago

Last modified 13 years ago

#1073 closed defect (fixed)

Improve instantiation speed (from MathCore)

Reported by: krsta Owned by: krsta
Priority: normal Milestone:
Component: Version:
Keywords: Cc: krsta, Adrian Pop

Description

The major bottleneck in instantiation is that the flat DAE is collected using listAppend, which copies the list for each call and is therefore very ineffective.

For example, to instantiate BondLib.Examples.ModelicaSpice.OrNorGate.TestOrNor takes
8m 10.578s on my laptop. If I comment out the collection of dae's it takes
2m 2.406s (the line 1699 in Inst.mo:

dae = Util.listFlatten({dae1,dae2,dae3,dae4,dae5});

Solution:
The dae should be passed along everywhere so elements (equations, variables, algorithms, etc) can be added using cons, thus eliminating all listAppends.

Change History (2)

comment:1 by Jan Brugård, 15 years ago

http://intranet/trac/mathmodelica/ticket/1478

This conclusion was a bit premature ;). The problem is in DAE.dumpStr. It takes up more than 50% of the time, probably due to stringAppend's all over. So that would be the first thing to fix, using the Print.printBuf approach with a preallocated size suitabable for the dae (estimated by e.g. traversal). It is however not so important since it isn't used when building, only when calling instantiateModel, or callning the kernel from command prompt. Therefore setting lower priority.

comment:2 by Martin Sjölund, 14 years ago

Adrian: Haven't we already fixed all of these things in the trunk? Time to close?

Note: See TracTickets for help on using tickets.