-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroup_summary.go
More file actions
214 lines (175 loc) · 7.77 KB
/
group_summary.go
File metadata and controls
214 lines (175 loc) · 7.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
Copyright 2026 The ARCORIS Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package bufferpool
// PoolGroupSummary is a lightweight group inspection view.
//
// Summary is read-only, caller-owned, copy-safe state. It does not retain full
// reports, run coordinator ticks, tick partitions, publish policy or budgets,
// apply pressure, execute Pool trim, or start/stop/retime schedulers. Unlike
// Snapshot, Summary intentionally omits full partition snapshots and all nested
// Pool class/shard snapshots. It is observational across partitions and does
// not claim a distributed transaction.
type PoolGroupSummary struct {
// Name is diagnostic group metadata.
Name string
// Lifecycle is the observed group lifecycle state.
Lifecycle LifecycleState
// Generation is the observed group state/event generation.
Generation Generation
// PolicyGeneration is the observed group runtime-policy generation.
PolicyGeneration Generation
// PressureSignal is the immutable pressure signal currently published into
// the group runtime snapshot.
PressureSignal PressureSignal
// Pressure is the effective pressure interpretation for aggregate group
// state.
Pressure PoolGroupPressureSnapshot
// Budget is the aggregate group budget projection.
Budget PoolGroupBudgetSnapshot
// CoordinatorStatus is the retained lightweight outcome of the last group
// coordinator cycle.
CoordinatorStatus PoolGroupControllerStatus
// Scheduler describes the group-local coordinator scheduler runtime.
Scheduler ControllerSchedulerSnapshot
// PartitionCount is the number of group-owned partitions.
PartitionCount int
// PoolCount is the aggregate number of Pools across group-owned partitions.
PoolCount int
// PoolCounters contains aggregate retained-storage Pool counters.
PoolCounters PoolCountersSnapshot
// LeaseCounters contains aggregate ownership-layer counters.
LeaseCounters LeaseCountersSnapshot
// Metrics is an aggregate projection derived from the summary sample.
Metrics PoolGroupMetrics
// Partitions contains lightweight summaries for group-owned partitions.
Partitions []PoolGroupPartitionSummary
}
// PoolGroupPartitionSummary is one named partition summary inside a group.
type PoolGroupPartitionSummary struct {
// Name is the group-local partition name.
Name string
// Lifecycle is the observed partition lifecycle state.
Lifecycle LifecycleState
// Generation is the observed partition state/event generation.
Generation Generation
// PolicyGeneration is the observed partition runtime-policy generation.
PolicyGeneration Generation
// PressureSignal is the partition runtime pressure signal.
PressureSignal PressureSignal
// Pressure is the partition effective pressure projection.
Pressure PartitionPressureSnapshot
// Budget is the partition budget projection.
Budget PartitionBudgetSnapshot
// ControllerStatus is the partition retained controller status.
ControllerStatus PoolPartitionControllerStatus
// Scheduler describes the partition-local scheduler runtime. Group summary
// only observes this child state; it does not manage partition schedulers.
Scheduler ControllerSchedulerSnapshot
// PoolCount is the number of Pools represented by the partition summary.
PoolCount int
// ActivePoolCount is the number of active Pool markers in the partition.
ActivePoolCount int
// DirtyPoolCount is the number of dirty Pool markers in the partition.
DirtyPoolCount int
// ActiveLeaseCount is the number of checked-out partition leases.
ActiveLeaseCount int
}
// Summary returns a lightweight group inspection summary.
//
// Snapshot remains the full diagnostic tree. Summary uses PoolPartition.Summary
// for child state, so it does not materialize nested Pool, class, or shard DTOs.
func (g *PoolGroup) Summary() PoolGroupSummary {
g.mustBeInitialized()
runtime := g.currentRuntimeSnapshot()
sample := PoolGroupSample{
Generation: g.generation.Load(),
PolicyGeneration: runtime.Generation,
Lifecycle: g.lifecycle.Load(),
PartitionCount: g.registry.len(),
Aggregate: PoolPartitionSample{
Generation: g.generation.Load(),
PolicyGeneration: runtime.Generation,
Lifecycle: g.lifecycle.Load(),
Scope: PoolPartitionSampleScopePartition,
},
}
partitions := make([]PoolGroupPartitionSummary, 0, g.registry.len())
for _, entry := range g.registry.entries {
partitionSummary := entry.partition.Summary()
partitions = append(partitions, newPoolGroupPartitionSummary(entry.name, partitionSummary))
addPartitionSummaryToGroupSample(&sample, partitionSummary)
}
sample.PoolCount = sample.Aggregate.PoolCount
sample.CurrentRetainedBytes = sample.Aggregate.CurrentRetainedBytes
sample.CurrentActiveBytes = sample.Aggregate.CurrentActiveBytes
sample.CurrentOwnedBytes = sample.Aggregate.CurrentOwnedBytes
pressure := PoolGroupPressureSnapshot(newEffectivePartitionPressureSnapshot(runtime.Policy.Pressure, runtime.Pressure, sample.Aggregate))
return PoolGroupSummary{
Name: g.name,
Lifecycle: sample.Lifecycle,
Generation: sample.Generation,
PolicyGeneration: runtime.Generation,
PressureSignal: runtime.Pressure,
Pressure: pressure,
Budget: newGroupBudgetSnapshot(runtime.Policy.Budget, sample),
CoordinatorStatus: g.ControllerStatus(),
Scheduler: g.coordinatorSchedulerSnapshot(runtime),
PartitionCount: sample.PartitionCount,
PoolCount: sample.PoolCount,
PoolCounters: sample.Aggregate.PoolCounters,
LeaseCounters: sample.Aggregate.LeaseCounters,
Metrics: newPoolGroupMetrics(g.name, sample),
Partitions: partitions,
}
}
func newPoolGroupPartitionSummary(name string, summary PoolPartitionSummary) PoolGroupPartitionSummary {
return PoolGroupPartitionSummary{
Name: name,
Lifecycle: summary.Lifecycle,
Generation: summary.Generation,
PolicyGeneration: summary.PolicyGeneration,
PressureSignal: summary.PressureSignal,
Pressure: summary.Pressure,
Budget: summary.Budget,
ControllerStatus: summary.ControllerStatus,
Scheduler: summary.Scheduler,
PoolCount: summary.PoolCount,
ActivePoolCount: summary.ActivePoolCount,
DirtyPoolCount: summary.DirtyPoolCount,
ActiveLeaseCount: summary.ActiveLeaseCount,
}
}
func addPartitionSummaryToGroupSample(sample *PoolGroupSample, summary PoolPartitionSummary) {
if sample == nil {
return
}
partitionSample := PoolPartitionSample{
Generation: summary.Generation,
PolicyGeneration: summary.PolicyGeneration,
Lifecycle: summary.Lifecycle,
Scope: PoolPartitionSampleScopePartition,
TotalPoolCount: summary.PoolCount,
SampledPoolCount: summary.PoolCount,
PoolCount: summary.PoolCount,
PoolCounters: summary.PoolCounters,
LeaseCounters: summary.LeaseCounters,
ActiveLeases: summary.ActiveLeaseCount,
CurrentRetainedBytes: summary.Metrics.CurrentRetainedBytes,
CurrentActiveBytes: summary.Metrics.CurrentActiveBytes,
CurrentOwnedBytes: summary.Metrics.CurrentOwnedBytes,
}
addPartitionSampleToGroupAggregate(&sample.Aggregate, partitionSample)
}
// IsEmpty reports whether summary contains no owned memory and no observed
// activity.
func (s PoolGroupSummary) IsEmpty() bool { return s.Metrics.IsZero() }