Author: wenyihu6 | Branch: oldmodel2 | Epic: CRDB-55052
-
[correctness]
highDiskSpaceUtilizationcomment is now stale (capacity_model.go:703-724): The comment explains thatfractionUsed = load/capacity = LogicalBytes / (LogicalBytes / diskUtil) = diskUtil. Under the new model, load=Used, capacity=Used+Available— the math still recovers actual disk utilization, but the comment references the old LogicalBytes-based derivation and is now misleading. -
[correctness]
minCapacityfloor is dramatically lower than the old floor (physical_model.go): The old model hadcpuCapacityFloorPerStore = 0.1 * 1e9(0.1 cores). The newminCapacity = 1.0means 1 ns/s — effectively zero CPU capacity. The old floor existed to prevent utilization from going to infinity on overloaded nodes (its comment explains this in detail). If a store has non-zero load and capacity=1 ns/s, utilization becomes astronomical. The PR description doesn't mention this behavioral change. Either the new floor should be comparable to the old one, or the PR should explain why the protection is no longer needed. -
[conventions]
Amp.SafeFormatdoesn't mark the float as safe for redaction (load.go):w.Printf("%.2f", af)passesafwithoutredact.SafeFloat. The established pattern in this file (e.g.,meanStoreLoad.SafeFormat) usesredact.SafeFloat()for floats. Fix with eitherredact.SafeFloat(float64(af))or by implementingSafeValue()(amp factors contain no PII). -
[conventions] Numbered list in
computePhysicalCPUdesign comment skips item 2 (physical_model.go:~line 80): The "Trade-off" section enumerates items 1, 3, 4, 5 — item 2 is missing.
-
[types]
Amptype has no doc comment (load.go): Every other named type in this file (LoadDimension,LoadValue,LoadVector, etc.) has a doc comment.Ampshould explain what it represents, its valid range, and that it converts logical to physical units. Same forAmpVector. -
[tests]
MakePhysicalRangeLoadhas no direct test (physical_model.go:270-282): The existingmma_conversion_test.goonly passesIdentityAmpVector()(amp=1.0), which is a no-op. A bug in dimension indexing (e.g., applying the wrong dimension's amp factor) would go undetected. Add a test with non-identity amp factors verifying each output field. -
[tests]
maxDiskSpaceAmplificationcap is never exercised in tests: The testdata covers amp=2.0 and amp=0.5 but never hits the 5.0 cap. Add a case likelogical-gib=10, used-gib=100to verify capping. -
[conventions]
amplificationFactors()shadows builtincap(mma_replica_store.go:296):cap := s.storeGossip.CachedCapacity()shadows the Go builtin. UsescorstoreCapinstead. -
[commits] Commit 1 message claims "wires it into all callers": The opening sentence says "wires it into all callers, replacing the logical (capped multiplier) model" but commit 1 only introduces the model. The wiring happens in commit 3. The message describes the full PR, not this specific commit.
-
[correctness] Old
computeCPUCapacityWithCapandcomputeStoreByteSizeCapacityare now dead code (capacity_model.go): After commit 3, these are only referenced from tests. Either remove them or add a comment noting they're retained as test baselines. -
[types] Compile-time assertion is one-directional and undocumented (
load.go):var _ [3 - NumLoadDimensions]struct{}catches additions but not removals. Add a bidirectional check and a comment explaining it guardsAmpVector.SafeFormat:// NumLoadDimensions must be 3. Update SafeFormat methods if changed. var _ [NumLoadDimensions - 3]struct{} var _ [3 - NumLoadDimensions]struct{}
-
[conventions] Redundant
float64()casts inMakePhysicalRangeLoad(physical_model.go:~line 700):requestCPUNanos,raftCPUNanos,writeBytesPerSec, andcpuNanosare alreadyfloat64. Thefloat64(cpuNanos)etc. wrappers are no-ops.
-
[types]
Ampis terse for this codebase: Other types use full words (LoadDimension,LoadValue).AmpFactorwould be clearer. -
[commits] Commits 1 and 2 lack
Release note:trailers: Only commit 3 has one. -
[commits] Commit 2 (minCapacity floor) could be folded into commit 1: It's ~10 lines and is a design decision of the physical model, not separable follow-up.
-
[tests]
fmtByteswrapper is redundant (physical_model_test.go):fmtBytesjust callsfmtIBytes— could usefmtIBytesdirectly. -
[correctness]
amplificationFactors()constructs a partial StoreDescriptor: OnlyCapacityandNodeCapacityare populated. IfcomputePhysicalStoreever reads other fields, this would silently break. The existing design note in the code acknowledges the dual-path concern, which is good.
- Excellent design documentation: The
computePhysicalCPUcomment with worked examples ("background in load, not capacity", "per-store load via CPUPerSecond", "capacity split evenly") is some of the best design documentation I've seen in this codebase. It makes the tradeoffs explicit and auditable. - Clean separation of concerns: The physical model cleanly separates store-level computation from range-level conversion via
MakePhysicalRangeLoad. - Good use of data-driven testing: 12 well-commented scenarios with inline derivations make the test easily auditable.
- Eliminates code duplication: The two separate
mmaRangeLoadimplementations are consolidated intoMakePhysicalRangeLoad. - Correct math: The model is internally consistent — sum of per-store loads recovers node usage (proved in the comment), and disk load/capacity recovers actual utilization.
- Simplification: Deferred — the code is newly introduced and already clean.
(made with /review-crdb)