Issue Task Closed

#107339[107337] Correct, simplify and speed up session garbage collection pr…

TYPO3 GmbH TYPO3com 08/27/25, 20:31 updated 08/27/25, 20:37

Description

…obability

The session garbage probability was calcluated wrongly. It randomly picked an integer between 0-99, but compared less-or-equal to the required probablity, so 99 counting falsely already as 100% and 1 counting falsesly as 2% (and so on). This is fixed by using a strict lesser-than comparison.

Also the random number generation was overcomplicated and statistically not uniform because it relied on the modulus of the divisor “100” being applied to a random number out of the range 0 to 2^31-1, whose maximum is not a multiple of 100, so the few “extra” numbers above the last whole multiple of 100 were a tiny bit more likely to be chosen (because they appear one time more often than the “missing” numbers up to 100 inside the “set” to randomly choose from). This was corrected by not taking the modulo of 100 of some huge random number, but by just getting a random number between 0-99 directly.

Also the cryptographically robust, but less than half as fast, function `random_int` was replaced by using `rand()` instead, to speed things up even further. Cryptographically robustness is not needed here.

This issue was automatically created from https://github.com/TYPO3/typo3/pull/583

Reviews 1

History 12

  1. Gerrit Code Review pushed patch set 1 for main to change 90495 status New Under Review 08/27/25, 20:31

  2. Garvin Hicking commented and changed status Under Review Closed 08/27/25, 20:37

    Dupe of #107337