Github messages for voidlinux
 help / color / mirror / Atom feed
From: tornaria <tornaria@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: pari: add config options
Date: Sat, 27 Mar 2021 23:28:30 +0100	[thread overview]
Message-ID: <20210327222830.io35388SfNsB_7gv84OLQ4Ae6dzovBM2OXLyayfXXW8@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-29635@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 2674 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/29635#issuecomment-808811231

Comment:
> This is such that pari is usable when building sagemath, which requires pthread.
As a matter of fact, I don't think sagemath requires pari built with pthread, or does it? (maybe it does need TLS at least? I don't know)

Anyway, sagemath won't work with pari-2.13 (for now, see https://trac.sagemath.org/ticket/30801) but that's for a different reason.

I run check as a "benchmark" to have hard data, but so far it seems to support what I thought:
 - using `pthreads` has a 25-45 % performance hit (25% for `gp-sta`, 45% for `gp-dyn`)
 - using `CFLAGS=-flto` doesn't change anything (even make `gp-dyn` slower).

A very stupid (non-)benchmark is to run
```
$ echo "sum(i=1,100 000 000, i);" | time gp -q
```
This doesn't substitute a proper benchmark, but at least it takes less than 5s to show a significant slowdown: it takes ~ 4.25s for me with the current binary from `pari-2.13.1_1`, but ~ 8.5s with `--mt=pthread` and more than 9s with `-flto` (less if using gp-sta, but we are shipping gp-dyn).

Note that all this "benchmark" is using a single-thread, because most (all?) of pari code which is written in C is single-thread. If you actually USE multiple threads you'll pay another 50% penalty. For instance:
```
echo "parsum(j=0,99,sum(i=j*1 000 000 + 1, (j+1)*1 000 000, i));" | time gp -q
```
Takes:
 - with single-thread gp-dyn: still 4.25s (no different than above)
 - with single-thread gp-sta: ~ 4s
 - with pthread gp-dyn: 12.87s user = 2.40s wall (8 core)
 - with pthread gp-sta: 7.28s user = 1.37s wall (8 core)

I'm not willing to pay a 3x penalty for using multi-thread. I can parallelize my programs in a different way, but of course not all tasks are suitable for that.

Here's a proposal (RFC):
 - start building and shipping gp-sta instead of gp-dyn (it's not clear what's the advantage of gp-dyn other than disk space).
 - add a build option to pari so that it's easy to compile pari with pthread support. It's even more important that the pthread version compiles gp-sta as the penalty is higher here.
 - start shipping the static library so external programs can static link with pari.
 - consider actually compiling both single-thread and multi-thread pari. The libraries have different SONAMES so that would not be a problem. As for the gp binary, we could ship them in separate packages, either conflicting or with different names and alternatives.

What do you think?

I'm willing to do all of the above and take over the package if the plan above sounds reasonable.

  parent reply	other threads:[~2021-03-27 22:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-20 17:20 [PR PATCH] " dkwo
2021-03-22  9:31 ` [PR PATCH] [Updated] " dkwo
2021-03-25  3:11 ` [wip] " ericonr
2021-03-25 20:21 ` [PR PATCH] [Updated] " dkwo
2021-03-25 20:23 ` dkwo
2021-03-26  9:51 ` dkwo
2021-03-26 16:30 ` ericonr
2021-03-26 17:09 ` dkwo
2021-03-26 17:42 ` ericonr
2021-03-27 14:53 ` [PR PATCH] [Updated] " dkwo
2021-03-27 14:58 ` dkwo
2021-03-27 19:39 ` tornaria
2021-03-27 22:28 ` tornaria [this message]
2021-03-27 22:38 ` tornaria
2021-03-28  6:12 ` ericonr
2021-03-28  6:13 ` ericonr
2021-03-28 10:10 ` [PR PATCH] [Updated] " dkwo
2021-03-28 10:11 ` dkwo
2021-03-28 14:23 ` tornaria
2021-03-28 19:15 ` [wip] " dkwo
2021-04-07 12:59 ` dkwo
2021-05-06 18:17 ` [PR PATCH] [Closed]: " dkwo
2021-08-17 19:06 ` tornaria
2021-08-17 19:42 ` ericonr
2021-08-17 21:41 ` tornaria
2021-08-18  9:15 ` dkwo
2021-08-18  9:15 ` [PR PATCH] [Closed]: " dkwo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210327222830.io35388SfNsB_7gv84OLQ4Ae6dzovBM2OXLyayfXXW8@z \
    --to=tornaria@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).