Skip to content

[stable35] Improve performance of snowflake ids in cron jobs - #65425

Open
backportbot[bot] wants to merge 3 commits into
stable35from
backport/64944/stable35
Open

backportbot[bot] wants to merge 3 commits into
stable35from
backport/64944/stable35

Conversation

@backportbot

@backportbot backportbot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Backport of PR #64944

Resolve #65434

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>

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.

[Bug]: SnowflakeGenerator passes arguments in wrong order to ISequence, causing duplicate IDs in Nextcloud 35

2 participants