Skip to content

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

Merged
CarlSchwan merged 3 commits into
stable35from
backport/64944/stable35
Oct 20, 2026
Merged

CarlSchwan merged 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>
@CarlSchwan
CarlSchwan merged commit 8399054 into stable35 Oct 20, 2026
196 of 203 checks passed
@CarlSchwan
CarlSchwan deleted the backport/64944/stable35 branch October 20, 2026 13:25
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for more than 7 days. As we do not monitor merged or closed pull requests, we are locking this pull request to prevent further comments from getting lost in the noise.
If you discovered any issues with this pull request, please open a new issue instead. In case you want to discuss this pull request or have further questions, please use our forum: https://help.nextcloud.com

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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

3 participants