[main] Make getTeamByServers O(1) in time (#12938)#13012
Merged
Conversation
gxglass
approved these changes
Apr 16, 2026
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
* Make getTeamByServers O(1) in time * address feedback
648cb8f to
20453d9
Compare
gxglass
reviewed
May 18, 2026
Contributor
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
gxglass
approved these changes
May 18, 2026
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
spraza
added a commit
to spraza/foundationdb
that referenced
this pull request
May 19, 2026
* Make getTeamByServers O(1) in time (apple#12938) * Make getTeamByServers O(1) in time * address feedback * address feedback
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.
Forward port of #12938.
Under certain workloads (large data movement, storage migration, etc.), with SHARD_ENCODE_LOCATION_METADATA enabled, DD can get indefinitely stuck at initialization time, because getTeamByServers function saturates the CPU and starves other critical DD actors to complete (symptom: txn_too_old).
This PR is a perf optimization that makes getTeamByServers O(1) instead of O(teams). Previously, for every team, we were doing expensive CPU operations.
Testing and analysis
100K results:
20260518-182541-praza-fwd-port-getTeamBySer-e4f98f2296c5aa71 compressed=True data_size=35941392 duration=4250904 ended=100000 fail=3 fail_fast=10 max_runs=100000 pass=99997 priority=100 remaining=0 runtime=1:05:02 sanity=False started=100000 stopped=20260518-193043 submitted=20260518-182541 timeout=5400 username=praza-fwd-port-getTeamByServers-main-20453d9676098857888b1d862830b25dadbbe55e
3 failures:
Investigating.
re (1):
I don't see an obvious way I am introducing non-determinism. Let me run this test 250K times, with my change, and without my change. I'll analyze if it's my change introducing non-determinism or it's there for this test to begin with.
running tests/slow/WriteDuringReadSwitchover.toml, 250K with fail fast of 10
with my change: 20260518-195437-praza-fwd-port-getTeamBySer-0eabfa61e1710d55 compressed=True data_size=35954619 fail_fast=10 max_runs=250000 priority=100 sanity=False submitted=20260518-195437 timeout=5400 username=praza-fwd-port-getTeamByServers-main-2def2427c3455c2dd02f76c32bbc730c71baf4dc
without my change: 20260518-200016-praza-fwd-port-getTeamBySer-651b00370962678e compressed=True data_size=35953413 fail_fast=10 max_runs=250000 priority=100 sanity=False submitted=20260518-200016 timeout=5400 username=praza-fwd-port-getTeamByServers-main-7462a3ade10dc699b20e5f4e3a89117896537885
re (2):
So shard_encode_location_metadata is off. My change should have no effect including on determinism. Easiest and quickest way to confirm: revert my change and expect same failure.
250K with my change: 20260519-190248-praza-fwd-port-getTeamBySer-dae6d43bf770574a compressed=True data_size=35954495 fail_fast=10 max_runs=250000 priority=100 sanity=False submitted=20260519-190248 timeout=5400 username=praza-fwd-port-getTeamByServers-main-2def2427c3455c2dd02f76c32bbc730c71baf4dc
250K without my change: 20260519-191053-praza-fwd-port-getTeamBySer-4c26026f397f51a8 compressed=True data_size=35952831 fail_fast=10 max_runs=250000 priority=100 sanity=False submitted=20260519-191053 timeout=5400 username=praza-fwd-port-getTeamByServers-main-revert-7462a3ade10dc699b20e5f4e3a89117896537885
I believe the issue is not related to my change here. It has to do with recovery and LR peeks, probably similar to #13238. Regardless see table [1] below which confirms that the tracedtoomanylines symptom exists in the baseline (without my changes) code as well.
re (3):
So could be my change.
250K with my change: 20260519-190345-praza-fwd-port-getTeamBySer-3f716bfae8fca260 compressed=True data_size=35954485 fail_fast=10 max_runs=250000 priority=100 sanity=False submitted=20260519-190345 timeout=5400 username=praza-fwd-port-getTeamByServers-main-2def2427c3455c2dd02f76c32bbc730c71baf4dc
250K without my change: 20260519-191040-praza-fwd-port-getTeamBySer-3dec3fa1685072e3 compressed=True data_size=35953095 fail_fast=10 max_runs=250000 priority=100 sanity=False submitted=20260519-191040 timeout=5400 username=praza-fwd-port-getTeamByServers-main-revert-7462a3ade10dc699b20e5f4e3a89117896537885
I believe the issue is not related to my change here. See table [1] below which confirms that the tracedtoomanylines symptom exists in the baseline (without my changes) code as well.
[1]:
Findings: across all 4 ensembles, every recorded failure is TracedTooManyLines in InventoryTestSomeWrites.toml or SidebandWithStatus.toml:
Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.
For Release-Branches
If this PR is made against a release-branch, please also check the following:
release-branchormainif this is the youngest branch)