Skip to content

[stable33] Improve performance of snowflake ids in cron jobs - #65423

Open
backportbot[bot] wants to merge 3 commits into
stable33from
backport/64944/stable33
Open

backportbot[bot] wants to merge 3 commits into
stable33from
backport/64944/stable33

Conversation

@backportbot

@backportbot backportbot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Backport of #64944

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

ISequence::nextId() takes the server id, the seconds and the
milliseconds, but the generator passed the seconds, the milliseconds and
the server id, so the sequences were keyed on the wrong values.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Store one slot per second of the TTL window and per millisecond in each
lock file, so generating an id only reads and writes 8 bytes instead of
decoding, filtering and rewriting a JSON map of the last 30 seconds.

The fsync is not needed as the files only coordinate processes running
at the same time.

Generating an id went from 660µs to 22µs with the temporary directory on
disk, and from 24µs to 11µs on tmpfs.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This allow to simplify a bit the code, also add a small description of
the algorithm.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
@CarlSchwan
CarlSchwan force-pushed the backport/64944/stable33 branch from 15d6811 to 91dc5bf Compare October 12, 2026 14:29
@CarlSchwan
CarlSchwan marked this pull request as ready for review October 13, 2026 07:18
@CarlSchwan
CarlSchwan requested a review from a team as a code owner October 13, 2026 07:18
@CarlSchwan
CarlSchwan requested review from Altahrim, leftybournes, salmart-dev and sorbaugh and removed request for a team October 13, 2026 07:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant