Skip to content

enhance: reduce quota and SetRates allocations - #22

Merged
sunby merged 1 commit into
codex/load-1m-segments-pr-stack-rebased-qv-workfrom
codex/quota-setrates-allocation-20260909
Sep 9, 2026
Merged

enhance: reduce quota and SetRates allocations#22
sunby merged 1 commit into
codex/load-1m-segments-pr-stack-rebased-qv-workfrom
codex/quota-setrates-allocation-20260909

Conversation

@sunby

@sunby sunby commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Summary

Reduce temporary allocation in the periodic quota calculation and SetRates fan-out, while keeping full SetRates snapshots and the existing quota-control data.

  • Reuse Coordinator calculation nodes and limiters. Restore limits, update flags and quota states each round; prune removed databases, collections and partitions, including when partition limits are disabled.
  • Read only collection properties needed by quota and omit unused partition-ID arrays. Preserve the old read path for other metadata implementations.
  • Capture the Proxy count once per full snapshot and avoid empty leaf maps. Each Proxy client copies its routing envelope and Base, including unknown fields, while sharing the immutable quota payload through synchronous fan-out, retries and encoding.
  • In DataCoord aggregate-metrics mode, accumulate display metrics directly by database/all rather than building per-collection display maps first. Preserve per-collection/per-partition disk-quota data, missing-collection handling and dropped-series cleanup. Correct an existing test fixture to populate the binlog counts already consumed by the baseline implementation.

No new configuration or protocol fields. No WAL, inspector, deployment or image changes. GetQuotaInfo still scans the segment cache, and GetAllCollectionNumRows still has its separate scan; incremental metadata statistics and delta SetRates are outside this PR.

Base and reference

Verification

Rerun on the submission base with -tags dynamic,test -gcflags="all=-N -l" -count=1, an isolated localhost etcd and the existing local native library build:

  • RootCoord QuotaCenter/QuotaCenterSuite, reset, disk-quota and request-limiter selections plus the new quota tests passed (24.719 s); DataCoord quota aggregation selections passed (1.611 s).

  • Complete distributed Proxy client, ProxyClientManager and rate-limiter-tree package tests passed.

  • New lifecycle/projection/denial-recovery, aggregate-control-data and concurrent SetRates codec/retry tests passed with -race across RootCoord, DataCoord and the distributed Proxy client.

  • Changed-code golangci-lint against the submission base passed for all four changed packages: 0 issues. New test files are included in the committed diff used for filtering. git diff --check passed.

  • make lint-fix ran gofumpt/gci and full root-module lint, then failed at internal/metastore/kv/querycoord/kv_catalog_test.go:372:15: undefined: mocks. That file has the identical blob in base and head; pkg/client lint stages were not reached. This unrelated baseline issue is not fixed here.

  • internal/core/run_clang_format.sh internal/core completed using clang-format 15.0.7. Formatter-only changes were reverted; the PR contains no C/C++ or unrelated formatting changes.

Behavioral coverage includes differential comparison with the old fresh-tree calculation; rate/property/config changes; deletion and recreation; clearing prior denial states; and Coordinator snapshot -> protobuf -> real Proxy limiter denial/recovery at cluster, database, collection and partition scope. Tests also cover Proxy-count changes, concurrent encoding with retries, independent routing headers and unknown fields, and aggregate/full metric mode changes without altering quota-control data.

The ownership audit traced quota-loop publication, synchronous Proxy fan-out, client retries, the registered gRPC codec and Proxy limiter consumption. The shared payload remains read-only, and later quota calculations do not mutate published snapshots.

Local microbenchmarks

100,000 collections, Apple M5, darwin/arm64, Go 1.26.5; -tags dynamic,test -gcflags="all=-N -l" -benchtime=3x -benchmem:

Operation Before B/op After B/op Before time/op After time/op
Quota calculation-tree reset 271,152,741 10,497,456 485.8 ms 241.5 ms
One Proxy SetRates request copy 33,530,432 176 59.5 ms 2.7 us
DataCoord aggregate GetQuotaInfo 107,708,472 33,157,592 716.8 ms 102.0 ms

The reset benchmark uses stable membership, no collection properties and disabled partition limits; both paths use the optimized property reader, excluding that reader's savings. The copy benchmark excludes serialization, network and Proxy processing. DataCoord uses one segment per collection in one database, with the identical fixture run against the unchanged baseline. These earlier function-level measurements are not production CPU, GC or search-latency results.

Remaining validation

Full make test-go and production-build end-to-end acceptance were not run. Actual Proxy process restart/network membership churn and same-load MixCoord CPU/alloc/latency A/B remain to be validated. Full scans and protobuf serialization remain; this PR does not claim to eliminate the CPU sawtooth.

Signed-off-by: sunby <sunbingyi1992@gmail.com>
@sunby
sunby merged commit b18065d into codex/load-1m-segments-pr-stack-rebased-qv-work Sep 9, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant