#4939: massive performance regression to primes_first_n
---------------------------+------------------------------------------------
 Reporter:  was            |       Owner:  was       
     Type:  defect         |      Status:  new       
 Priority:  blocker        |   Milestone:  sage-3.2.3
Component:  number theory  |    Keywords:            
---------------------------+------------------------------------------------
 This is a doctest in arith.py:
 {{{
     This is very fast, because we leave the output as a PARI object:
         sage: v = primes_first_n(10^6, leave_pari=True)
         sage: len(v)
 }}}
 In fact, the above is now way way slower than doing leave_pari=False!  So
 the doctest is blatantly wrong multiple times.   It also says:
 {{{
         leave_pari -- bool (default: False) if True the returned list
                     is a PARI list; this is *vastly* (10 times!)
 }}}

 On sage.math it is not very fast, and also uses 1.5GB RAM, which is a
 major problem for doctesting this on my build farm, where some machines
 have only 1GB RAM.  Also, I don't think it is reasonable to require 1.5GB
 RAM for standard doctests.
 {{{
 wst...@sage:~$ sage
 ----------------------------------------------------------------------
 | Sage Version 3.2.2, Release Date: 2008-12-18                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: time v = primes_first_n(10^6,leave_pari=True)
 CPU times: user 24.42 s, sys: 0.63 s, total: 25.05 s
 Wall time: 25.05 s
 sage: get_memory_usage()
 1454.27734375
 }}}

 For comparison:
 {{{
 wst...@sage:~/sage/devel/sage/sage/rings$ sage
 ----------------------------------------------------------------------
 | Sage Version 3.2.2, Release Date: 2008-12-18                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: time v = primes_first_n(10^6, leave_pari=False)
 CPU times: user 0.42 s, sys: 0.19 s, total: 0.61 s
 Wall time: 0.61 s
 sage: get_memory_usage()
 927.67578125
 }}}

 The documentation also says:
 {{
 However, PARI integers are much different than
 SAGE integers.  If you use this option the lower
 bound must be 2.
 }}}
 which is patently false now.

 An easy fix is to get rid entirely of the leave_pari=True option.  It was
 only ever there because it used to be really fast.  But now it is 50%
 better.

 The problem is also in prime_range:
 {{{
 sage: time w = prime_range(10^6)
 CPU times: user 0.03 s, sys: 0.00 s, total: 0.03 s
 Wall time: 0.03 s
 sage: time w = prime_range(10^6,leave_pari=True)
 CPU times: user 0.95 s, sys: 0.02 s, total: 0.97 s
 Wall time: 0.97 s
 }}}

 The easiest solution is to simply delete all this "leave_pari" stuff.
 It's totally useless, bad from an api point of view, and gains only a
 little speed.  Writing code against this api that uses the option would be
 particularly stupid, since in the feature we could easily have a native
 prime_range that is way faster than pari's, hence code that tries to be
 clever would be slower.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4939>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to