-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scope: remove fmt.Sprintf() string concatenation and improve tag merge (
#61) * tags: save an alloc by creating the full stat key in serializeTags Instead of serializing the tags then appending them to the stat name, combine those operations so that there is only one alloc instead of two if tags are present. Benchmark Comparison: (Note: BenchmarkSerializeTags now does a little more work, but NewCounterWithTags is improved) benchmark old ns/op new ns/op delta BenchmarkStore_MutexContention-8 120 114 -5.00% BenchmarkStore_NewCounterWithTags-8 512 465 -9.18% BenchmarkSerializeTags-8 426 441 +3.52% benchmark old allocs new allocs delta BenchmarkStore_MutexContention-8 0 0 +0.00% BenchmarkStore_NewCounterWithTags-8 4 3 -25.00% BenchmarkSerializeTags-8 3 3 +0.00% benchmark old bytes new bytes delta BenchmarkStore_MutexContention-8 2 2 +0.00% BenchmarkStore_NewCounterWithTags-8 336 272 -19.05% BenchmarkSerializeTags-8 256 272 +6.25% * stats: benchmark Scope functions and methods Benchmark results: goos: darwin goarch: amd64 pkg: github.com/lyft/gostats BenchmarkStore_ScopeWithTags-8 1000000 1404 ns/op 576 B/op 6 allocs/op BenchmarkStore_ScopeNoTags-8 1000000 1092 ns/op 672 B/op 8 allocs/op * stats: Scope: remove fmt.Sprintf() string concatenation and improve tag merge Improve the performance of Scope* methods by not using fmt.Sprintf() to concatenate strings and re-using the parent's tags when the child scope has none (tags are never modified - they are only used to generate the stat key name). Benchmark Results: benchmark old ns/op new ns/op delta BenchmarkStore_ScopeWithTags-8 1417 1268 -10.52% BenchmarkStore_ScopeNoTags-8 1100 527 -52.09% benchmark old allocs new allocs delta BenchmarkStore_ScopeWithTags-8 6 4 -33.33% BenchmarkStore_ScopeNoTags-8 8 4 -50.00% benchmark old bytes new bytes delta BenchmarkStore_ScopeWithTags-8 576 544 -5.56% BenchmarkStore_ScopeNoTags-8 672 304 -54.76% * stats: don't use pointer to nullSink in benchmarks * stats: use impossibly long flush interval (because it doesn't matter) * stats_test: remove unneeded global variables
- Loading branch information
1 parent
1a040be
commit bade9ed
Showing
4 changed files
with
90 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters