Review 13.4 Merged

91275[TASK] Improve user session garbage collection algorithm

Christian Kuhn CR +2 V +2 Easy +2 −3 updated 10/27/25, 16:23

Commit message

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

Also, the random number generation was over-complicated 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 signed 32 bit maximum, not being 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.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
  • Verified V +2 Done
    • Christian Kuhn +2
    • core-ci +1 CI

Issues 1

Files 1

Review log 34

  1. Christian Kuhn uploaded patch set 1 10/27/25, 16:05

  2. core-ci voted on patch set 1 V +1 10/27/25, 16:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87678

  3. Christian Kuhn voted on patch set 1 CR +2 V +2 10/27/25, 16:23

  4. Christian Kuhn merged patch set 2 10/27/25, 16:23