Opened 6 years ago

Closed 6 years ago

#18952 closed defect (fixed)

heavy performance regression with real/imag(ex)

Reported by: rws Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: performance Keywords:
Cc: Merged in:
Authors: Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #18980 Stopgaps:

Status badges

Description

This is the first Symbench test. Sage around 4.3 took 0.3s (see http://wiki.sagemath.org/symbench#Problem_R1) but Sage-6.8rc0 needs 10 minutes:

sage: def f(z): return sqrt(1/3)*z^2 + i/3
sage: real(f(f(f(f(f(f(f(f(f(f(i/2)))))))))))

while

sage: %timeit real(f(f(f(f(f(f(f(f(f(f(i/2)))))))))).expand())
10 loops, best of 3: 23.5 ms per loop

A simplified version of this is:

sage: real((((((((((sqrt(3)+I)^2+1)^2+1)^2+1)^2+1)^2+1)^2+1)^2+1)^2+1)^2+1)^2

Change History (8)

comment:1 Changed 6 years ago by rws

Profiling with callgrind reveals remarkable things, even with only 6 f's. Although Pynac accounts for less than 1 per cent of the time, a whopping 150,000 of numerics are created; 88,000 calls to ex::is_zero; 50,000 to Integer(long). The 3,400 calls of atan2 show that the formula power(abs(basis),c)*exp(-d*atan2(b,a))*cos(c*atan2(b,a)+d*log(abs(basis))) is used to compute real((1/3)^(1/2)) over and over.

The simplest solution would be to expand before taking the real part in Pynac.

However, there is probably more in this use case regarding performance improvement.

comment:2 Changed 6 years ago by rws

  • Dependencies set to pynac-0.3.9.3/-0.4.3
  • Report Upstream changed from N/A to Fixed upstream, in a later stable release.

comment:3 Changed 6 years ago by vdelecroix

  • Reviewers set to Vincent Delecroix
  • Status changed from new to needs_review

comment:4 Changed 6 years ago by vdelecroix

Ralf,

With #18980 the problem seems to disappear. Should we close it as a duplicate?

Vincent

comment:5 Changed 6 years ago by vdelecroix

  • Status changed from needs_review to needs_info

comment:6 Changed 6 years ago by rws

  • Dependencies changed from pynac-0.3.9.3/-0.4.3 to #18980
  • Milestone changed from sage-6.8 to sage-duplicate/invalid/wontfix
  • Report Upstream changed from Fixed upstream, in a later stable release. to N/A
  • Status changed from needs_info to needs_review

comment:7 Changed 6 years ago by vdelecroix

  • Status changed from needs_review to positive_review

comment:8 Changed 6 years ago by vbraun

  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.