Skip to content

Commit

Permalink
Merge pull request #2441 from influxdata/preallocate_groupid
Browse files Browse the repository at this point in the history
perf: preallocate GroupID
  • Loading branch information
docmerlin authored Dec 2, 2020
2 parents a8b6378 + 6da524a commit 81be964
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [#1839](https://github.com/influxdata/kapacitor/pull/1839): Add Subscription path configuration option to allow Kapacitor to run behind a reverse proxy, thanks @aspring
- [#2055](https://github.com/influxdata/kapacitor/pull/2055): Add support for correlate in the Alerta AlertNode, thanks @nermolaev!
- [#2409](https://github.com/influxdata/kapacitor/pull/2409): Optionally use kapacitor alert details as opsgenie description text, thanks @JamesClonk!
- [#2441](https://github.com/influxdata/kapacitor/pull/2441): Preallocate GroupIDs for increased performance by reducing allocations.

## v1.5.7 [2020-10-27]

Expand Down
14 changes: 14 additions & 0 deletions models/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ func ToGroupID(name string, tags map[string]string, dims Dimensions) GroupID {
return NilGroup
}
var buf strings.Builder
l := 0
if dims.ByName {
// add capacity for the name + "\n"
l += len(name) + 1
}
for i, d := range dims.TagNames {
if i != 0 {
// add capacity for the comma after the tagnames
l++
}
// add capacity for the name length, and the tag length, and the "="
l += len(d) + len(tags[d]) + 1
}
buf.Grow(l)
if dims.ByName {
buf.WriteString(name)
// Add delimiter that is not allowed in name.
Expand Down

0 comments on commit 81be964

Please sign in to comment.