1

Topic: Reduce LLVM build time

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): Unreleased 1.3.2 from Github
- Deployed with iRedMail Easy or the downloadable installer? Download from Github
- Linux/BSD distribution name and version: FreeBSD 12.1-RELEASE-p10
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL 12.x
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

On FreeBSD all packages are build from the `Ports`.
The LLVM is build as a dependency for PostgreSQL.
As there is no explicit configuration, all the defaults are used.
The defaults are likely to be configured as to be used for development, opposed to as a dependency.
For development there are cross-ompilers, debuggers, (extensive) documentation.
The build of LLVM takes a good chunk of the iRedMail installation (six hours in one test)

I checked and asked in the FreeBSD foruns and got some feedback. Link below:
Bare minimum build of LLVM

Below is a suggestions (TO BE Tested!)

# cd /usr/ports/devel/llvm90
# make config
┌────────────────── llvm90-9.0.1_2 ───────────────────┐
│ ┌────────────────────────────────────────────┐ │  
│ │+[x] BE_AMDGPU    AMD GPU backend (required by mesa)                      │ │  
│ │+[x] CLANG        Build clang                                             │ │  
│ │+[ ] COMPILER_RT  Sanitizer libraries                                     │ │  
│ │+[ ] DOCS         Build and/or install documentation                      │ │  
│ │+[ ] ELFV2        [PowerPC64] Use OpenPOWER ELF ABI v2 by default         │ │  
│ │+[ ] EXTRAS       Extra clang tools                                       │ │  
│ │+[ ] GOLD         Build the LLVM Gold plugin for LTO                      │ │  
│ │+[x] LIT          Install lit and FileCheck test tools                    │ │  
│ │+[x] LLD          Install lld, the LLVM linker                            │ │  
│ │+[ ] LLDB         Install lldb, the LLVM debugger                         │ │  
│ │+[x] LLD_LINK     Link ld.lld as ld to clang uses it                      │ │  
│ │+[x] OPENMP       Install libomp, the LLVM OpenMP runtime library         │ │  
│ │+[ ] PYCLANG      Install python bindings to libclang                     │ │  
│ │──────────────────── BACKENDS ──────────────────│ │  
│ │+( ) BE_FREEBSD   Backends for FreeBSD architectures                      │ │  
│ │+(*) BE_NATIVE    Backend(s) for this architecture (X86)                  │ │  
│ │+( ) BE_STANDARD  All non-experimental backends                           │ │  
│ └────────────────────────────────────────────┘ │  
└───────────────────────────────────────────────┘

2 (edited by angeloklin 2020-10-19 16:56:05)

Re: Reduce LLVM build time

Tested the reduced configuration of LLVM.

The original build time of LLVM alone, with default, all included setup was 6:08:08. With the reduced configuration the time was 2:49:39.

Testing environment:
- macOS Mojave 10.14.6
- VMware Fusion 10.1.6 (VM 4GB, 20GB)
- iRedMail 1.3.2 (from Github)
- FreeBSD 12.1, Postgres 12.x

NOTE: I am testing iRedMail installation focus on the building of the packages and overall install process. I am not testing functionality either manually or with any regression test or script. If iRedMail's team likes the idea, I would assume they have proper testing sets.

The modifications were:

# = = = = = = = = = =
# ./functions/package_freebsd.sh
. . .
freebsd_make_conf_plus_option 'LICENSES_ACCEPTED' 'DCC'

    for p in \
        . . .
        devel_cmake \
        devel_llvm90 \           ### add this line
        . . .
        www_sogo4; do
        mkdir -p /var/db/ports/${p} >> ${INSTALL_LOG} 2>&1
    done

    # cmake. DEPENDENCE
    cat > /var/db/ports/devel_cmake/options <<EOF
OPTIONS_FILE_UNSET+=DOCS
OPTIONS_FILE_UNSET+=MANPAGES
EOF

    # llvm DEPENDENCE            ### add this block
    cat > /var/db/ports/devel_llvm90/options <<EOF
OPTIONS_FILE_UNSET+=BE_AMDGPU
OPTIONS_FILE_SET+=CLANG
OPTIONS_FILE_UNSET+=COMPILER_RT
OPTIONS_FILE_UNSET+=DOCS
OPTIONS_FILE_UNSET+=ELFV2
OPTIONS_FILE_UNSET+=EXTRAS
OPTIONS_FILE_UNSET+=GOLD
OPTIONS_FILE_SET+=LIT
OPTIONS_FILE_SET+=LLD
OPTIONS_FILE_UNSET+=LLDB
OPTIONS_FILE_SET+=LLD_LINK
OPTIONS_FILE_SET+=OPENMP
OPTIONS_FILE_UNSET+=PYCLANG
OPTIONS_FILE_UNSET+=BE_FREEBSD
OPTIONS_FILE_UNSET+=BE_STANDARD
OPTIONS_FILE_SET+=BE_NATIVE
EOF
. . .

3

Re: Reduce LLVM build time

This option is so simple that it hurts, not considering it in the first place. I guess we do not want to rock the boat by removing things.

Simply disable LLVM for Postgres. Thanks for the pople in the FreeBSD forum for the idea.
Bare minimum build of LLVM

Postgres uses LLVM since version 11 to optimise queries by creating specific functions on the fly.
Some reference from the documentation: 31.1. What Is JIT compilation?

It is a choice (as always). Some might prefer to have this ON and benefit from this feature. Some might prefer to turn it OFF. Criteria can be the hardware configuration available. Compilation time vs running time. Size and flow of messages on the mail server.
I run a $4 VCS with 1GB memory on a personal domain. I really do not need to wait six hours for LLVM to compile, and I do not believe I would benefit from this. Someone else's needs would be different.

The specifics:
- Build time for LLVM: 0:00:00. Postgres is one think that link LLVM as a dependency. Turn that OFF, and you do not need LLVM at all.

# = = = = = = = = = =
# ./functions/packages_freebsd.sh
. . .
    # PostgreSQL
    cat > /var/db/ports/databases_postgresql${PGSQL_VERSION}-server/options <<EOF
. . .
OPTIONS_FILE_SET+=LLVM      # Change FROM SET
OPTIONS_FILE_UNSET+=LLVM    # TO UNSET

ClamAV also offers to build with LLVM, but it is UNSET by default

# = = = = = = = = = =
# ./functions/packages_freebsd.sh
    # ClamAV. REQUIRED.
    cat > /var/db/ports/security_clamav/options <<EOF
. . .
OPTIONS_FILE_SET+=DOCS      # BTW: This should be UNSET
. . .
OPTIONS_FILE_UNSET+=LLVM    # Default is already UNSET

Good luck and stay safe.

4

Re: Reduce LLVM build time

Good catch, I think we can disable llvm directly. Will commit this change later.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

5

Re: Reduce LLVM build time

After removed LLVM, the installation toke about 70 minutes for PGSQL backend on my local testing machine. smile

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

6

Re: Reduce LLVM build time

ZhangHuangbin wrote:

After removed LLVM, the installation toke about 70 minutes for PGSQL backend on my local testing machine. smile

Sounds great.

In case you do not follow too closelly, FreeBSD 12.2 is scheduled to be released in a week's time, on the 27/Oct.

FreeBSD 12.2 Release Process

Looking forward to upgrade (reinstall) my systems with FreeBSD 12.2 plus iRedMail 1.3.2, and leave Python 2.7 behind for good.

BTW: Is the conversion from Py2.7 to Py3.8 close to be finished and v1.3.2 soon after?

Also, I have sent some other suggestions on configs for the `options`.

Cheers
Keep it safe.

7

Re: Reduce LLVM build time

angeloklin wrote:

In case you do not follow too closelly, FreeBSD 12.2 is scheduled to be released in a week's time, on the 27/Oct.

I planned to release iRedMail-1.3.2 (or 1.4.0) this week.
OpenBSD 6.8 was out days ago, and new iRedMail release supports it too.
I will try to setup FreeBSD 12.2 locally and catch up, this way new iRedMail might be delayed for 1 week (installing from ports takes too long).

angeloklin wrote:

BTW: Is the conversion from Py2.7 to Py3.8 close to be finished and v1.3.2 soon after?

Py 2to3 migration has been finished, including iRedAPD, mlmmjadmin, iRedAdmin(-Pro), they will be shipped in upcoming iRedMail release.

angeloklin wrote:

Also, I have sent some other suggestions on configs for the `options`.

Please share them here, we still have some time.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

8

Re: Reduce LLVM build time

Another plan is we tag new iRedMail release before FreeBSD 12.2 announced, and re-tag it with commits to support 12.2.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee