On Wednesday, June 4, 2014 7:32:38 AM UTC-7, Markus-Ludwig Wermer wrote:
>
> Some basic multiplications were more than 10 times faster in Sage 6.1.1.
> Is there a way to speed up those multiplications?
>
We can get a reasonable first impression of what is taking most time by
profiling some code:
%prun MultiplicationTime(a*t,t,32000)
1 1.334 1.334 1.812 1.812
<ipython-input-3-9aaa272deab5>:1(MultiplicationTime)
64006 0.297 0.000 0.421 0.000 {method 'element_from_data'
of 'sage.rings.finite_rings.element_givaro.Cache_givaro' objects}
128007 0.055 0.000 0.068 0.000
finite_field_givaro.py:359(gen)
64006 0.038 0.000 0.459 0.000
finite_field_givaro.py:226(_element_constructor_)
64006 0.028 0.000 0.056 0.000 gap.py:1648(is_GapElement)
64015 0.028 0.000 0.028 0.000 {isinstance}
64002 0.018 0.000 0.018 0.000
laurent_polynomial_ring.py:707(polynomial_ring)
128007 0.012 0.000 0.012 0.000 {method 'gen' of
'sage.rings.finite_rings.element_givaro.Cache_givaro' objects}
%prun MultiplicationTime(a*t,a,32000)
1 4.315 4.315 5.699 5.699
<ipython-input-3-9aaa272deab5>:1(MultiplicationTime)
64001 0.725 0.000 0.737 0.000
polynomial_ring.py:306(_element_constructor_)
64001 0.350 0.000 0.501 0.000 {method 'element_from_data'
of 'sage.rings.finite_rings.element_givaro.Cache_givaro' objects}
128002 0.065 0.000 0.079 0.000
finite_field_givaro.py:359(gen)
64001 0.060 0.000 0.067 0.000
finite_field_givaro.py:174(degree)
64001 0.049 0.000 0.550 0.000
finite_field_givaro.py:226(_element_constructor_)
128002 0.048 0.000 0.048 0.000 {isinstance}
64001 0.036 0.000 0.072 0.000 gap.py:1648(is_GapElement)
64001 0.029 0.000 0.029 0.000
laurent_polynomial_ring.py:707(polynomial_ring)
128002 0.013 0.000 0.013 0.000 {method 'gen' of
'sage.rings.finite_rings.element_givaro.Cache_givaro' objects}
64001 0.007 0.000 0.007 0.000 {method 'exponent' of
'sage.rings.finite_rings.element_givaro.Cache_givaro' objects}
This suggests that element_from_data uses significant time. This is a
generic conversion routine! Looking around in the call graph would probably
show where this happens. Given most elements lie in the right ring already,
it may well be possible to avoid it and/or optimize the code path through
it for frequent cases ( little tip-off is the freqent use of is_GapElement,
which probably should not be checked at all, because this code doesn't ever
seem to come near GapLib. It's also cheap, though, so by itself not really
responsible for a lot of time use)
You may also want to check if the degradation in performance is uniform.
The examples you are trying are quite basic and perhaps not typical for
most use (getting an idea of what "most use" is would already be very
useful in general and certainly for optimizing!). Is the current
implementation perhaps better in other cases?
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.