Bug 279908 - devel/cmake: autogen (moc/uic) processes don't respect MAKE_JOBS_NUMBER
Summary: devel/cmake: autogen (moc/uic) processes don't respect MAKE_JOBS_NUMBER
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (group)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-22 13:41 UTC by Anton Saietskii
Modified: 2024-06-29 06:16 UTC (History)
2 users (show)

See Also:
jhale: maintainer-feedback+


Attachments
v1 (575 bytes, patch)
2024-06-23 14:49 UTC, Jason E. Hale
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Saietskii 2024-06-22 13:41:44 UTC
I'm not sure how to prove it, but just noticed that while c++ parts are running as expected with jobs=1, moc uses jobs=ncpu causing unnecessary system load despite DISABLE_MAKE_JOBS=poudriere being present.
Comment 1 Jason E. Hale freebsd_committer freebsd_triage 2024-06-22 17:09:12 UTC
This probably is more of a CMake problem than specific to qt6-base.

Could you try adding CMAKE_ARGS+=-DCMAKE_AUTOGEN_PARALLEL=${MAKE_JOBS_NUMBER} to the Makefile and see if that helps?
Comment 2 Anton Saietskii 2024-06-23 11:19:11 UTC
(In reply to Jason E. Hale from comment #1)

Thanks for suggestion.
Interesting, especially while documentation [0] states that default is unset. However, there's also option with similar name [1], which "sets the number of threads/processes to the number of physical CPUs on the host system" if empty, so I'll definitely try that.

Perhaps there's also some option exist to log process spawns?

[0]: https://cmake.org/cmake/help/latest/variable/CMAKE_AUTOGEN_PARALLEL.html
[1]: https://cmake.org/cmake/help/latest/prop_tgt/AUTOGEN_PARALLEL.html
Comment 3 Jason E. Hale freebsd_committer freebsd_triage 2024-06-23 14:49:19 UTC
Created attachment 251648 [details]
v1

This should fix the issue. I'm not seeing multiple moc processes spawn when DISABLE_MAKE_JOBS=yes.
Comment 4 Anton Saietskii 2024-06-25 11:15:01 UTC
(In reply to Jason E. Hale from comment #3)

I can confirm that with the patch, no excess moc processes being spawned.

BTW, either CMake documentation is incorrect or it's the bug.
I have 1 CPU, 4 physical cores, HT -- and previously, 8 moc processed were spawned, which doesn't align with "number of threads/processes to the number of physical CPUs" in any way. However, I don't work with CMake extensively, so not willing to report this upstream.

P.S. I wish someone from gecko@ could review PRs so quick...
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-06-29 05:43:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3ecb58c61953097c5b5331c3e11ae8fced410ca9

commit 3ecb58c61953097c5b5331c3e11ae8fced410ca9
Author:     Jason E. Hale <jhale@FreeBSD.org>
AuthorDate: 2024-06-29 05:20:51 +0000
Commit:     Jason E. Hale <jhale@FreeBSD.org>
CommitDate: 2024-06-29 05:20:51 +0000

    Mk/Uses/cmake.mk: Respect MAKE_JOBS_NUMBER

    Pass -DCMAKE_AUTOGEN_PARALLEL:STRING="${MAKE_JOBS_NUMBER}" to avoid
    spawning more moc and uic processes than the user has specified via
    MAKE_JOBS_NUMBER and to limit to 1 if the user has DISABLE_MAKE_JOBS
    set.

    PR:             279908
    Reported by:    Anton Saietskii <vsasjason@gmail.com>

 Mk/Uses/cmake.mk | 1 +
 1 file changed, 1 insertion(+)
Comment 6 Jason E. Hale freebsd_committer freebsd_triage 2024-06-29 06:16:45 UTC
(In reply to Anton Saietskii from comment #4)

> I can confirm that with the patch, no excess moc processes being spawned.

Thanks for confirming! Committed.

> BTW, either CMake documentation is incorrect or it's the bug.
> I have 1 CPU, 4 physical cores, HT -- and previously, 8 moc processed were spawned,
> which doesn't align with "number of threads/processes to the number of physical CPUs"
> in any way.
> However, I don't work with CMake extensively, so not willing to report this upstream.

It's probably more of a documentation bug by means of generalization. CMake, at least for FreeBSD, uses what is reported by `sysctl -n hw.ncpu` to determine the number of CPUs for this purpose. On my laptop, I also have 1 CPU with 4 physical cores with HT and the output of that command is "8", so it would make sense that up to and including 8 processes would be spawned before this change.

> P.S. I wish someone from gecko@ could review PRs so quick...

I don't like commenting on FreeBSD ports teams that I'm not involved with, but some are way more understaffed than others and sometimes sadly only consist of one person, so it may take more time for them to address PRs. We at kde@ are currently a relatively robust team and do our best to stay on top of things. Even still, we do miss things such as this and appreciate your report.