Skip to content

Commit

Permalink
Set namespace and ID as NoFinalize (#956)
Browse files Browse the repository at this point in the history
This allows the session to avoid cloning these on the WriteTagged
operation, which will save two allocations for each datapoint
  • Loading branch information
arnikola authored Sep 27, 2018
1 parent 835df4d commit 3190128
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/query/storage/m3/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ func newUnaggregatedClusterNamespace(
if err := def.Validate(); err != nil {
return nil, err
}

ns := def.NamespaceID
// Set namespace to NoFinalize to avoid cloning it in write operations
ns.NoFinalize()
return &clusterNamespace{
namespaceID: def.NamespaceID,
namespaceID: ns,
options: ClusterNamespaceOptions{
attributes: storage.Attributes{
MetricsType: storage.UnaggregatedMetricsType,
Expand All @@ -308,8 +312,12 @@ func newAggregatedClusterNamespace(
if err := def.Validate(); err != nil {
return nil, err
}

ns := def.NamespaceID
// Set namespace to NoFinalize to avoid cloning it in write operations
ns.NoFinalize()
return &clusterNamespace{
namespaceID: def.NamespaceID,
namespaceID: ns,
options: ClusterNamespaceOptions{
attributes: storage.Attributes{
MetricsType: storage.AggregatedMetricsType,
Expand Down
2 changes: 2 additions & 0 deletions src/query/storage/m3/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ func (s *m3storage) Write(
id := query.Tags.ID()
// TODO: Consider caching id -> identID
identID := ident.StringID(id)
// Set id to NoFinalize to avoid cloning it in write operations
identID.NoFinalize()
common := &writeRequestCommon{
store: s,
annotation: query.Annotation,
Expand Down

0 comments on commit 3190128

Please sign in to comment.