WIP: feat: refactor the service manager to achieve 30x faster server initialization #1482

Draft
gamesguru wants to merge 16 commits from gamesguru/continuwuity:guru/fix/cli-optimization/faster-startup-safer-shutdown into main
Contributor

Refactor the service manager to achieve 30x faster server initialization and avoiding full database scans by implementing index-aware presence resets on a background thread.

And fix the shutdown manager by terminating workers in the correct order of their dependency hierarchy, thereby preventing shutdown hangs and resulting in an extremely fast shutdown sequence which gives special preference only to the RocksDB worker and the integrity of the database.

Pull request checklist:

  • This pull request targets the main branch, and the branch is named something other than
    main.
  • I have written an appropriate pull request title and my description is clear.
  • I understand I am responsible for the contents of this pull request.
  • I have followed the [contributing guidelines][c1]:
    • My contribution follows the [code style][c2], if applicable.
    • I ran [pre-commit checks][c1pc] before opening/drafting this pull request.
    • I have [tested my contribution][c1t] (or proof-read it for documentation-only changes)
      myself, if applicable. This includes ensuring code compiles.
    • My commit messages follow the [commit message format][c1cm] and are descriptive.
    • I have written a [news fragment][n1] for this PR, if applicable.
Refactor the service manager to achieve 30x faster server initialization and avoiding full database scans by implementing index-aware presence resets on a background thread. And fix the shutdown manager by terminating workers in the correct order of their dependency hierarchy, thereby preventing shutdown hangs and resulting in an extremely fast shutdown sequence which gives special preference only to the RocksDB worker and the integrity of the database. **Pull request checklist:** <!-- You need to complete these before your PR can be considered. If you aren't sure about some, feel free to ask for clarification in #dev:continuwuity.org. --> - [x] This pull request targets the `main` branch, and the branch is named something other than `main`. - [x] I have written an appropriate pull request title and my description is clear. - [x] I understand I am responsible for the contents of this pull request. - I have followed the [contributing guidelines][c1]: - [x] My contribution follows the [code style][c2], if applicable. - [x] I ran [pre-commit checks][c1pc] before opening/drafting this pull request. - [x] I have [tested my contribution][c1t] (or proof-read it for documentation-only changes) myself, if applicable. This includes ensuring code compiles. - [x] My commit messages follow the [commit message format][c1cm] and are descriptive. - [x] I have written a [news fragment][n1] for this PR, if applicable<!--(can be done after hitting open!)-->.
fix: restore less ominous warning log from guru/nightly
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m44s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 21m36s
6a4f968f5f
gamesguru changed title from Refactor the service manager to achieve 30x faster server initialization to feat: refactor the service manager to achieve 30x faster server initialization 2026-03-03 08:47:50 +00:00
@ -10,3 +10,3 @@
events::{
AnyGlobalAccountDataEventContent, AnyRoomAccountDataEventContent,
GlobalAccountDataEventType, RoomAccountDataEventType,
RoomAccountDataEventType,
Member

FWIW, I believe this change is covered by #1479, so you may want to rebase depending on the outcome of that one.

FWIW, I believe this change is covered by #1479, so you may want to rebase depending on the outcome of that one.
gamesguru marked this conversation as resolved
Jade changed title from feat: refactor the service manager to achieve 30x faster server initialization to WIP: feat: refactor the service manager to achieve 30x faster server initialization 2026-03-03 18:32:36 +00:00
Merge branch 'main' into guru/fix/cli-optimization/faster-startup-safer-shutdown
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 4m19s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 36m19s
de9b531955
Author
Contributor

Commits affecting the below files will be removed to other branches. It is advised to use the git CLI when reviewing my PRs, especially large ones.

# setup
git remote add ellis-gg https://forgejo.ellis.link/gamesguru/continuwuity.git
git fetch --all

# configure lgb alias in .gitconfig
git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%aN>%Creset%n' --abbrev-commit --date=relative"

# view raw branch history
git lgb ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown

# view full diff against main (using '...' to see changes Diverged from main)
git diff origin/main...ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown

# view diff excluding the undesired files
IGNORE_FILES_LIST=(
  src/api/router/auth.rs
  src/api/server/utils.rs
  src/core/config/mod.rs
  src/database/engine/db_opts.rs
  src/service/resolver/actual.rs
  src/service/resolver/dns.rs
  src/service/server_keys/acquire.rs
)
IGNORE="${IGNORE_FILES_LIST[@]/#/:^}"

git diff origin/main...ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown -- $IGNORE
# "stat" only diff (+/- count per file)
git diff --stat origin/main...ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown -- $IGNORE
Commits affecting the below files will be removed to other branches. It is advised to use the `git` CLI when reviewing my PRs, especially large ones. ```shell # setup git remote add ellis-gg https://forgejo.ellis.link/gamesguru/continuwuity.git git fetch --all # configure lgb alias in .gitconfig git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%aN>%Creset%n' --abbrev-commit --date=relative" # view raw branch history git lgb ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown # view full diff against main (using '...' to see changes Diverged from main) git diff origin/main...ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown # view diff excluding the undesired files IGNORE_FILES_LIST=( src/api/router/auth.rs src/api/server/utils.rs src/core/config/mod.rs src/database/engine/db_opts.rs src/service/resolver/actual.rs src/service/resolver/dns.rs src/service/server_keys/acquire.rs ) IGNORE="${IGNORE_FILES_LIST[@]/#/:^}" git diff origin/main...ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown -- $IGNORE # "stat" only diff (+/- count per file) git diff --stat origin/main...ellis-gg/guru/fix/cli-optimization/faster-startup-safer-shutdown -- $IGNORE ```
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 4m19s
Required
Details
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 36m19s
Required
Details
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u guru/fix/cli-optimization/faster-startup-safer-shutdown:gamesguru-guru/fix/cli-optimization/faster-startup-safer-shutdown
git switch gamesguru-guru/fix/cli-optimization/faster-startup-safer-shutdown
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
continuwuation/continuwuity!1482
No description provided.