Ask Your Question
1

If I compile Sage from source, will it start up faster?

asked 2020-12-27 15:10:08 +0200

Dr. Banana gravatar image

Basically the thing that annoys me about sage is the slow start-up time. It takes about 13 seconds to get to the prompt. Now, I had compiled sage before, but I mistakenly did that with the -march=generic flag. Now, if I compile it with the -march=native (znver1 in my case) and -03 flags, will it start up faster? Has anybody else compiled it with -03? Any other flags I should be aware of?

edit retag flag offensive close merge delete

Comments

1

Not expert enough to post an answer, and in particular I cannot answer your question about flags, but I would tend to think Sage can only be faster if you build it from source.

If you care about speed, the best way to find out is probably to try it. If you do, please keep us posted with the result!

You could even try several methods of installing and report comparing startup time and any other speed benchmarks you have:

  • install from your distribution (if available)
  • install from binaries from the Sage download pages
  • install using Conda
  • install using Docker
  • build from source (now a lot faster than it used to, since it can use many system packages)
slelievre gravatar imageslelievre ( 2020-12-27 15:47:52 +0200 )edit

On a 2014 MacBook Air, with Sage latest develop compiled from source, I get

$ time sage -c "print(version())"
SageMath version 9.3.beta4, Release Date: 2020-12-14

real    0m5.482s
user    0m2.286s
sys 0m1.293s
slelievre gravatar imageslelievre ( 2020-12-27 15:49:34 +0200 )edit

Do you have sufficient RAM? Do you use swap? Do you have enough disk space?

slelievre gravatar imageslelievre ( 2020-12-27 15:50:15 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-28 11:58:03 +0200

Dr. Banana gravatar image

updated 2020-12-28 13:38:49 +0200

Emmanuel Charpentier gravatar image

@slelievre I compiled sagemath using march=native -O3 -fno-plt and unfortunatlely I have to say that sage is now slower (I think). The thing you have to know is, sagemath speeds up if I use schedutil as my scaling governor. Unfortunately I can't remember whether I was using schedutil or powersave when I was testing the binary version (probably powersave though). So I downloaded the binary version again (turns out out you can have both installed side-by-side)(it's kind of creepy that the binary version remembers my previous inputs). Here are results from old the binary version:

Running benchmark 0 Benchmark 0:
   Factor the following polynomial over
       the rational numbers: (x^97+19*x+1)*(x^103-19*x^97+14)*(x^100-1) Time: 0.2822810000000002 seconds
   Running benchmark 1 Find the
   Mordell-Weil group of the elliptic
   curve 5077A using mwrank Time:
   0.4469660000000002 seconds Running benchmark 2 Some basic arithmetic
   with very large Integer numbers:
   '3^1000001 * 19^100001 Time:
   0.01994899999999955 seconds Running benchmark 3 Some basic arithmetic
   with very large Rational numbers:
   '(2/3)^100001 * (17/19)^100001 Time:
   0.028340999999999728 seconds Running benchmark 4 Rational polynomial
   arithmetic using Sage. Compute
   (x^29+17*x-5)^200. Time:
   0.009201000000000015 seconds Running benchmark 5 Rational polynomial
   arithmetic using Sage. Compute (x^19
   - 18*x + 1)^50 one hundred times. Time: 0.10662800000000017 seconds
   Running benchmark 6 Compute the
   p-division polynomials of y^2 = x^3 +
   37*x - 997 for primes p < 40. Time:
   0.05905899999999997 seconds Running benchmark 7 Compute the Mordell-Weil
   group of y^2 = x^3 + 37*x - 997.
   Time: 0.37592800000000004 seconds
   Running benchmark 8 %time
   sum(1/(x^2), x,1,100000) CPU times:
   user 1min 11s, sys: 1.14 s, total:
   1min 12s

Wall time: 27.9 s

Here are results from the new binary version (powersave):

Running benchmark 0
Benchmark 0: Factor the following polynomial over
    the rational numbers: (x^97+19*x+1)*(x^103-19*x^97+14)*(x^100-1)
Time: 0.2790720000000002 seconds
Running benchmark 1
Find the Mordell-Weil group of the elliptic curve 5077A using mwrank
Time: 0.4314460000000002 seconds
Running benchmark 2
Some basic arithmetic with very large Integer numbers: '3^1000001 * 19^100001
Time: 0.019366999999999912 seconds
Running benchmark 3
Some basic arithmetic with very large Rational numbers: '(2/3)^100001 * (17/19)^100001
Time: 0.028370000000000672 seconds
Running benchmark 4
Rational polynomial arithmetic using Sage. Compute (x^29+17*x-5)^200.
Time: 0.008942000000000228 seconds
Running benchmark 5
Rational polynomial arithmetic using Sage. Compute (x^19 - 18*x + 1)^50 one hundred times.
Time: 0.106522 seconds
Running benchmark 6
Compute the p-division polynomials of y^2 = x^3 + 37*x - 997 for primes p < 40.
Time: 0.05832100000000029 seconds
Running benchmark 7
Compute the Mordell-Weil group of y^2 = x^3 + 37*x - 997.
Time: 0.3272319999999995 seconds
Running benchmark 8

From compiled version (powersave):

Running benchmark 0
Benchmark 0: Factor the following polynomial over
    the rational numbers: (x^97+19*x+1)*(x^103-19*x^97+14)*(x^100-1)
Time: 0.3547199999999995 seconds
Running benchmark 1
Find the Mordell-Weil group of the elliptic curve 5077A using mwrank
Time: 0.43139200000000066 seconds
Running benchmark 2
Some basic arithmetic with very large Integer numbers: '3^1000001 * 19^100001
Time: 0.019306000000000267 seconds
Running benchmark 3
Some basic arithmetic with very large Rational numbers: '(2/3)^100001 * (17/19)^100001
Time: 0.028086999999999307 seconds
Running benchmark 4
Rational polynomial arithmetic using Sage. Compute (x^29+17*x-5)^200.
Time: 0.008855999999999753 seconds
Running benchmark 5
Rational polynomial arithmetic using Sage. Compute (x^19 - 18*x + 1)^50 one hundred times.
Time: 0.10795900000000103 seconds
Running benchmark 6
Compute the p-division polynomials of y^2 = x^3 + 37*x - 997 for primes p < 40.
Time: 4.499999999918458e-05 seconds
Running benchmark 7
Compute the Mordell-Weil group of y^2 = x^3 + 37*x - 997.
Time: 2.1000000000270802e-05 seconds
Running benchmark 8

What's interesting is that the compiled version is slower in benchmark 0. Could this be due to a missing dependency or something? Also the compiled version is faster at benchmarks 7 and 8. Now for my own test: the time it takes to compute sum(1/(x^2), x,1,100000):

Binary version (powersave):
CPU times: user 1min 11s, sys: 1.1 s, total: 1min 12s
Wall time: 27.4 s

Compiled version (powersave):
CPU times: user 1min 23s, sys: 1.3 s, total: 1min 25s
Wall time: 28.5 s

So the compiled version is slower in this regard.

Binary version (schedutil):
Running benchmark 0
Benchmark 0: Factor the following polynomial over
    the rational numbers: (x^97+19*x+1)*(x^103-19*x^97+14)*(x^100-1)
Time: 0.14427600000000007 seconds
Running benchmark 1
Find the Mordell-Weil group of the elliptic curve 5077A using mwrank
Time: 0.1471680000000002 seconds
Running benchmark 2
Some basic arithmetic with very large Integer numbers: '3^1000001 * 19^100001
Time: 0.0064669999999997785 seconds
Running benchmark 3
Some basic arithmetic with very large Rational numbers: '(2/3)^100001 * (17/19)^100001
Time: 0.009400999999999993 seconds
Running benchmark 4
Rational polynomial arithmetic using Sage. Compute (x^29+17*x-5)^200.
Time: 0.00301399999999985 seconds
Running benchmark 5
Rational polynomial arithmetic using Sage. Compute (x^19 - 18*x + 1)^50 one hundred times.
Time: 0.03593299999999999 seconds
Running benchmark 6
Compute the p-division polynomials of y^2 = x^3 + 37*x - 997 for primes p < 40.
Time: 3.0999999999892225e-05 seconds
Running benchmark 7
Compute the Mordell-Weil group of y^2 = x^3 + 37*x - 997.
Time: 1.2999999999596668e-05 seconds
Running benchmark 8

Compiled version (schedutil):

Running benchmark 0
Benchmark 0: Factor the following polynomial over
    the rational numbers: (x^97+19*x+1)*(x^103-19*x^97+14)*(x^100-1)
Time: 0.17197400000000007 seconds
Running benchmark 1
Find the Mordell-Weil group of the elliptic curve 5077A using mwrank
Time: 0.14492799999999972 seconds
Running benchmark 2
Some basic arithmetic with very large Integer numbers: '3^1000001 * 19^100001
Time: 0.006648000000000209 seconds
Running benchmark 3
Some basic arithmetic with very large Rational numbers: '(2/3)^100001 * (17/19)^100001
Time: 0.009484000000000048 seconds
Running benchmark 4
Rational polynomial arithmetic using Sage. Compute (x^29+17*x-5)^200.
Time: 0.0030330000000002855 seconds
Running benchmark 5
Rational polynomial arithmetic using Sage. Compute (x^19 - 18*x + 1)^50 one hundred times.
Time: 0.0348070000000007 seconds
Running benchmark 6
Compute the p-division polynomials of y^2 = x^3 + 37*x - 997 for primes p < 40.
Time: 5.2999999999858716e-05 seconds
Running benchmark 7
Compute the Mordell-Weil group of y^2 = x^3 + 37*x - 997.
Time: 1.1999999999900979e-05 seconds
Running benchmark 8

My own tests:

Binary version (schedutil):
CPU times: user 40.2 s, sys: 547 ms, total: 40.8 s
Wall time: 12.1 s

Compiled version (schedutil):
CPU times: user 46.3 s, sys: 621 ms, total: 46.9 s
Wall time: 12.6 s

P.S. I didn't delete the .sage directory before compiling.

edit flag offensive delete link more

Comments

Reformatted a bit in order to be able to read the damn thing...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-12-28 13:39:20 +0200 )edit

Regarding the comment about history:

it's kind of creepy that the binary version remembers my previous inputs

the history of commands is stored in ~/.sage/ipython-5.0.0/profile_default/history.sqlite, so it's not attached to any particular version of Sage you are using. It is up to you to create and use separate DOT_SAGE folders or different ipython profiles if you wish.

slelievre gravatar imageslelievre ( 2020-12-28 21:52:33 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-27 15:10:08 +0200

Seen: 202 times

Last updated: Dec 28 '20