Bug 274192 - lang/perl5*: Drop threads option and always enable it
Summary: lang/perl5*: Drop threads option and always enable it
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Mathieu Arnold
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-01 08:00 UTC by Daniel Engberg
Modified: 2024-08-30 11:07 UTC (History)
3 users (show)

See Also:


Attachments
Patch for perl5 (4.82 KB, patch)
2023-10-01 08:00 UTC, Daniel Engberg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Engberg freebsd_committer freebsd_triage 2023-10-01 08:00:25 UTC
Created attachment 245347 [details]
Patch for perl5

Looking at other distros and/or repos (Alpine, Arch, Debian, Fedora, Homebrew, openSUSE) this is hardcoded as always on except for Gentoo where it's enabled by default but optional. I can't find any obvious reason not to have it always on today and it also reduces a lot of complexity within the tree figuring out what port options were used during build (see graphics/ImageMagick* for example).

Compile tested on FreeBSD 13.2-RELEASE (amd64)
Comment 1 Tom Hukins 2023-10-01 18:20:29 UTC
Please don't apply this patch.  A threaded perl runs noticeably slower than a non-threaded perl.

When building perl for general use, enabling threads makes the perl exexcutable compatible with a wider range of perl scripts.  If you know the scripts you will run don't need threads, disabling "usethreads" will help performance.
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2023-10-01 18:33:51 UTC
Hi Tom,

Do you have any examples where you can replicate this?

Best regards,
Daniel
Comment 3 Tom Hukins 2023-10-02 08:36:10 UTC
To measure this, you can build perl from source with threads enabled and disabled.  See perl's INSTALL file for details.

I build a non-threaded perl with `sh Configure -des && make test` and a threaded perl with `sh Configure -des -Dusethreads && make test`.

You will notice that building perl without threads is the default behaviour, due to their slowness.
Comment 4 Daniel Engberg freebsd_committer freebsd_triage 2023-10-02 18:21:18 UTC
Depending on options different sets of tests is executed so make test can't be used to determine performance differences?

tests=1185659 vs tests=1197409
Comment 5 Tom Hukins 2023-10-02 18:39:28 UTC
Thank you for your investigation.  I perhaps assumed too much knowledge of perl: `make test` runs perl's test suite to check it has compiled correctly.  It is not designed as a benchmark.  Once you have compiled perl, you will need to run a suitable set of benchmarks.  What's suitable for you may not be suitable for someone else.

However, I'll repeat my request that we keep the existing option: many organisations that push perl to its limits (and many that don't) have noticed performance benefits from compiling perl with threads disabled.  That's why it's the default when you run `sh Configure`.
Comment 6 Daniel Engberg freebsd_committer freebsd_triage 2023-10-02 19:08:46 UTC
Just tried a simple benchmark and threaded actually performed better (not by much but a few percent) on my Tigerlake based laptop.

Code:

use Benchmark;
$main::x=join("",(a..z))x200000;

&timethis(100,\&test);

sub test {
   $main::x =~ s/(.*?)I/$1/isge;
   }
Comment 7 Daniel Engberg freebsd_committer freebsd_triage 2024-06-01 19:09:19 UTC
Mat, ping?
Comment 8 Mathieu Arnold freebsd_committer freebsd_triage 2024-06-02 06:17:59 UTC
If we keep the option, I don't see any reason to switch the default for existing Perls, I'll investigate with perl-devel and maybe it'll be switched for 5.42.
Comment 9 Daniel Engberg freebsd_committer freebsd_triage 2024-06-02 06:51:35 UTC
Thanks, please consider to drop it in 5.40 as this seems to works out just fine in other major distros.
Comment 10 Daniel Engberg freebsd_committer freebsd_triage 2024-06-10 18:35:54 UTC
Ping about 5.40
Comment 11 Mathieu Arnold freebsd_committer freebsd_triage 2024-06-10 19:42:34 UTC
As I said in comment 8, just above, I'll switch in perl5-devel, and then it will be in 5.42 when it gets released next year.
Comment 12 commit-hook freebsd_committer freebsd_triage 2024-08-30 11:07:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=06754026a9ab4804ceeeda7fca869e0e5cd45b0c

commit 06754026a9ab4804ceeeda7fca869e0e5cd45b0c
Author:     Mathieu Arnold <mat@FreeBSD.org>
AuthorDate: 2024-08-30 10:51:38 +0000
Commit:     Mathieu Arnold <mat@FreeBSD.org>
CommitDate: 2024-08-30 11:06:18 +0000

    lang/perl5-devel: update to 5.41.3

    While there, drop the THREADS option [1]

    PR:             274192 [1]

 lang/perl5-devel/Makefile                             | 10 ++++------
 lang/perl5-devel/distinfo                             |  6 +++---
 lang/perl5-devel/files/patch-perl.c                   |  4 ++--
 lang/perl5-devel/files/patch-t_porting_customized.dat |  4 ++--
 lang/perl5-devel/pkg-plist                            |  8 ++++++++
 lang/perl5-devel/version.mk                           |  2 +-
 6 files changed, 20 insertions(+), 14 deletions(-)