Skip to content

Commit

Permalink
More struct packing (#3908)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdarulis authored Nov 8, 2021
1 parent 5268eee commit 513748e
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 123 deletions.
4 changes: 2 additions & 2 deletions src/aggregator/aggregator/aggregation_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
)

type aggregationKey struct {
aggregationID aggregation.ID
storagePolicy policy.StoragePolicy
pipeline applied.Pipeline
storagePolicy policy.StoragePolicy
aggregationID aggregation.ID
numForwardedTimes int
idPrefixSuffixType IDPrefixSuffixType
}
Expand Down
54 changes: 27 additions & 27 deletions src/aggregator/aggregator/counter_elem_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions src/aggregator/aggregator/elem_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ type metricElem interface {
// ElemData are initialization parameters for an element.
type ElemData struct {
ID id.RawID
StoragePolicy policy.StoragePolicy
AggTypes maggregation.Types
Pipeline applied.Pipeline
StoragePolicy policy.StoragePolicy
NumForwardedTimes int
IDPrefixSuffixType IDPrefixSuffixType
ListType metricListType
Expand All @@ -165,7 +165,6 @@ type elemBase struct {
aggTypesOpts maggregation.TypesOptions
id id.RawID
sp policy.StoragePolicy
useDefaultAggregation bool
aggTypes maggregation.Types
aggOpts raggregation.Options
parsedPipeline parsedPipeline
Expand All @@ -178,11 +177,12 @@ type elemBase struct {
listType metricListType

// Mutable states.
tombstoned bool
closed bool
cachedSourceSets []map[uint32]*bitset.BitSet // nolint: structcheck
// a cache of the lag metrics that don't require grabbing a lock to access.
forwardLagMetrics map[forwardLagKey]tally.Histogram
forwardLagMetrics map[forwardLagKey]tally.Histogram
tombstoned bool
closed bool
useDefaultAggregation bool // really immutable, but packed w/ the rest of bools
}

// consumeState is transient state for a timedAggregation that can change every flush round.
Expand Down Expand Up @@ -227,11 +227,11 @@ func (f *flushState) close() {
}

type elemMetrics struct {
sync.RWMutex
scope tally.Scope
updatedValues tally.Counter
retriedValues tally.Counter
forwardLags map[forwardLagKey]tally.Histogram
mtx sync.RWMutex
}

type forwardLagKey struct {
Expand All @@ -243,17 +243,17 @@ type forwardLagKey struct {
}

func (e *elemMetrics) forwardLagMetric(key forwardLagKey) tally.Histogram {
e.RLock()
e.mtx.RLock()
m, ok := e.forwardLags[key]
if ok {
e.RUnlock()
e.mtx.RUnlock()
return m
}
e.RUnlock()
e.Lock()
e.mtx.RUnlock()
e.mtx.Lock()
m, ok = e.forwardLags[key]
if ok {
e.Unlock()
e.mtx.Unlock()
return m
}
jitterApplied := "false"
Expand Down Expand Up @@ -287,7 +287,7 @@ func (e *elemMetrics) forwardLagMetric(key forwardLagKey) tally.Histogram {
120 * time.Second,
})
e.forwardLags[key] = m
e.Unlock()
e.mtx.Unlock()
return m
}

Expand Down
Loading

0 comments on commit 513748e

Please sign in to comment.