I think I have found the two problems. The main problem is the code to
simplify the abs function. A second problem is the call of $sum.
1.
A lot of integrals in rtest_integrate.mac generates results with the abs
function. The arguments are often very complicated expressions. If we
optimize the order of the tests to check for an abs function which can
be simplified, the first problem vanish.
This is the time we need without simplification of the abs function and
without a mfuncall to $sum:
Evaluation took:
132.202 seconds of real time
129.056066 seconds of total run time (128.172011 user, 0.884055
system)
[ Run times consist of 1.716 seconds GC time, and 127.341 seconds
non-GC time. ]
97.62% CPU
3,761 forms interpreted
781 lambdas converted
194,452,049,033 processor cycles
167 page faults
1,443,865,872 bytes consed
This is the time with the code to simplify the abs function:
Evaluation took:
348.177 seconds of real time
342.733420 seconds of total run time (340.697292 user, 2.036128
system)
[ Run times consist of 3.184 seconds GC time, and 339.550 seconds
non-GC time. ]
98.44% CPU
3,761 forms interpreted
781 lambdas converted
517,854,003,391 processor cycles
176 page faults
2,982,591,112 bytes consed
It is possible to optimize the code for the simplification of the abs
function. We no longer have an increase of the time we need to evaluate
the examples in rtest_integrate:
Evaluation took:
131.521 seconds of real time
128.280017 seconds of total run time (127.191949 user, 1.088068
system)
[ Run times consist of 1.632 seconds GC time, and 126.649 seconds
non-GC time. ]
97.54% CPU
3,761 forms interpreted
781 lambdas converted
193,546,958,721 processor cycles
169 page faults
1,444,221,840 bytes consed
2.
There is a second problem with the functions dosum and $sum. The effect
is smaller.
If we change the call of dosum to a mfuncall of $sum we get an increase
of about 50% of the time we need to evaluate the examples of
rtest_integrate.
Evaluation took:
190.489 seconds of real time
187.807736 seconds of total run time (186.343645 user, 1.464091
system)
[ Run times consist of 2.592 seconds GC time, and 185.216 seconds
non-GC time. ]
98.59% CPU
3,761 forms interpreted
781 lambdas converted
283,408,115,046 processor cycles
114 page faults
2,347,904,960 bytes consed
The problem is, that the function dosum does not return a well
simplified noun form. At first the summand is well simplified, but dosum
destroys this well simplified summand and returns a result with missing
simp flags. If we call $sum we get a well simplified noun form, but we
go two times through the simplifier with the same expression. Therefore
we get a considerable increase of the evaluation time.
The first problem is easy to solve. I will commit on optimized order of
checks.
Dieter Kaiser