xz: Change the cap of the default -T0 memlimit for 32-bit xz.

The SIZE_MAX / 3 was 1365 MiB. 1400 MiB gives little more room
and it looks like a round (artificial) number in --info-memory
once --info-memory is made to display it.

Also, using #if avoids useless code on 64-bit builds.
This commit is contained in:
Lasse Collin 2022-04-14 14:50:17 +03:00
parent c77fe55ddb
commit 1d59289727
1 changed files with 3 additions and 1 deletions

View File

@ -279,15 +279,17 @@ hardware_init(void)
// /proc/meminfo as the starting point. // /proc/meminfo as the starting point.
memlimit_mt_default = total_ram / 4; memlimit_mt_default = total_ram / 4;
#if SIZE_MAX == UINT32_MAX
// A too high value may cause 32-bit xz to run out of address space. // A too high value may cause 32-bit xz to run out of address space.
// Use a conservative maximum value here. A few typical address space // Use a conservative maximum value here. A few typical address space
// sizes with Linux: // sizes with Linux:
// - x86-64 with 32-bit xz: 4 GiB // - x86-64 with 32-bit xz: 4 GiB
// - x86: 3 GiB // - x86: 3 GiB
// - MIPS32: 2 GiB // - MIPS32: 2 GiB
const size_t mem_ceiling = SIZE_MAX / 3; // About 1365 GiB on 32-bit const size_t mem_ceiling = 1400U << 20;
if (memlimit_mt_default > mem_ceiling) if (memlimit_mt_default > mem_ceiling)
memlimit_mt_default = mem_ceiling; memlimit_mt_default = mem_ceiling;
#endif
return; return;
} }