perf(syncer): skip no-op commits in group membership/ownership reconcile#550
Closed
somethingnew2-0 wants to merge 1 commit into
Closed
perf(syncer): skip no-op commits in group membership/ownership reconcile#550somethingnew2-0 wants to merge 1 commit into
somethingnew2-0 wants to merge 1 commit into
Conversation
The reconcile loops committed once per group, but authoritative sync writes to Okta, not the DB, so those commits are no-ops — two DB round trips per group (SELECT + COMMIT) where one suffices. Commit only after a group that actually wrote to the DB (non-authoritative drift), plus every _RECONCILE_COMMIT_EVERY groups to release the read snapshot the per-group SELECTs hold. The per-group SELECT stays, so reads remain fresh under READ COMMITTED — no stale start-of-run snapshot and no bulk load into memory. This is the change that moves the needle: measurement showed the sync is bounded by the serial per-group DB round trips, not Okta fetch concurrency (raising --group-fetch-concurrency had no effect against a ~50%-utilized rate limit). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
Not sure if I like this solution. It feels like a hack and database commits probably don't outweigh database loads of group memberships being reducing the number of requests to the database being made. |
Collaborator
Author
|
Closing for now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Profiling the sync cron showed the group membership/ownership phase dominates the ~26-min run, and — surprisingly — raising
--group-fetch-concurrencydidn't help: Okta's/api/v1/groups*rate limit sat at ~50% utilization regardless of the setting. That rules out fetch concurrency as the bottleneck; the sync is bound by the serial per-group DB round trips in the reconcile loops.Each group did a
SELECT(current members/owners) and acommit()— two round trips per group. But in authoritative mode the reconciliation writes to Okta, not the DB, so the per-groupcommit()is a no-op: pure overhead, ~N wasted round trips.This commits only when a group actually wrote to the DB (non-authoritative drift), plus once every
_RECONCILE_COMMIT_EVERY(100) groups to release the read snapshot theSELECTs hold. For a steady-state authoritative run that roughly halves the per-group DB round trips.What it deliberately does not do
SELECTstays, so each group reads fresh committed state.SELECTsees a fresh snapshot of committed data, including UI changes made mid-run. The periodic commit just bounds how long that read snapshot pinsxmin.Notes
🤖 Generated with Claude Code