<p>This PR is to address two different but related issues:</p>
<ol>
<li>On 32bit systems, available virtual memory is in practise very limited and easy to exhaust on systems with many CPUs. (RhBug:1729382)</li>
<li>There are systems with lot of CPUs (virtual or otherwise) but relatively limited memory, where just looking at available CPUs causes severe trashing. (RhBug:1118734)</li>
</ol>
<p>This effectively caps the number of threads on 32bit to just four, but tunable by changing the thread size estimate. Number of processes is capped to gigabytes of memory or number of CPU's, whichever is smaller, and tunable by changing the process size estimate.</p>
<p>The series adds a new macro primitive for getting system memory information and builds bunch of heuristics on top of those. There's a lot of subtleties involved and no doubt some of them I've gotten wrong here, so this PR is not intended for immediate merging, but more as a basis for discussion and other feedback.</p>
<p>What bothers me personally here is that it adds quite a bit of brittle heuristics that we never needed before, heuristics that will inevitably go wrong. The 32bit thread issue could be handled by just slapping a hard limit, with just a couple of lines of code. OTOH, the many cpus but little memory -case is legit and solving does require heuristics no matter what. And since heuristics will go wrong sooner or later, there needs to be tunables, which is why so much of this is done in macro level despite being somewhat painful.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/rpm-software-management/rpm/pull/821'>https://github.com/rpm-software-management/rpm/pull/821</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Move smp-related macros from platform to main macros</li>
  <li>Add some macro primitives for retrieving system memory information</li>
  <li>Limit build parallelism by available memory too, add tunables (#804)</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/rpm-software-management/rpm/pull/821/files#diff-0">build/parseSpec.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/rpm-software-management/rpm/pull/821/files#diff-1">doc/manual/macros</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/rpm-software-management/rpm/pull/821/files#diff-2">macros.in</a>
    (27)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/rpm-software-management/rpm/pull/821/files#diff-3">platform.in</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/rpm-software-management/rpm/pull/821/files#diff-4">rpmio/macro.c</a>
    (67)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/rpm-software-management/rpm/pull/821.patch'>https://github.com/rpm-software-management/rpm/pull/821.patch</a></li>
  <li><a href='https://github.com/rpm-software-management/rpm/pull/821.diff'>https://github.com/rpm-software-management/rpm/pull/821.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/rpm-software-management/rpm/pull/821?email_source=notifications&email_token=ADLPZUZWW6625NTTHK6IN4TQF2B5PA5CNFSM4IOUPT4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGYYWYA">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ADLPZUYDUQ3STQDHNRVDP7DQF2B5PANCNFSM4IOUPT4A">mute the thread</a>.<img src="https://github.com/notifications/beacon/ADLPZU7GCXNPOO4F3KEP4Q3QF2B5PA5CNFSM4IOUPT4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGYYWYA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/rpm-software-management/rpm/pull/821?email_source=notifications\u0026email_token=ADLPZUZWW6625NTTHK6IN4TQF2B5PA5CNFSM4IOUPT4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGYYWYA",
"url": "https://github.com/rpm-software-management/rpm/pull/821?email_source=notifications\u0026email_token=ADLPZUZWW6625NTTHK6IN4TQF2B5PA5CNFSM4IOUPT4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGYYWYA",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>