Bug 274192 - lang/perl5*: Drop threads option and always enable it
Summary: lang/perl5*: Drop threads option and always enable it
Status: New
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: 2023-10-02 19:08 UTC (History)
2 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;
   }