Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce allocations on Query's io.Stringer implementation #6713

Merged
merged 1 commit into from
May 24, 2016

Conversation

e-dard
Copy link
Contributor

@e-dard e-dard commented May 24, 2016

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

A query's String method can be called multiple times per query. This commit
ensures all calls to query.String share use of a strings.NewReplacer rather than allocating one per call. A strings.Replacer is safe for concurrent use by multiple goroutines.

This approximately halves the number of allocations for the included benchmark.

BenchmarkQuery_String-4               100000         23209 ns/op       51841 B/op         98 allocs/op

to

BenchmarkQuery_String-4               300000          5545 ns/op        2304 B/op         58 allocs/op

@jsternberg
Copy link
Contributor

👍 but needs a changelog entry.

@benbjohnson
Copy link
Contributor

👍

A query's String method is called multiple times per query. This commit
ensures all calls to query.String share use of a strings.NewReplacer.

This approximately halves the number of allocations for the benchmarked
query.
@e-dard e-dard force-pushed the er-query-string branch from 1c6c9f7 to 853a95e Compare May 24, 2016 13:27
@e-dard e-dard merged commit 4a36530 into master May 24, 2016
@e-dard e-dard deleted the er-query-string branch May 24, 2016 13:38
@timhallinflux timhallinflux added this to the 1.0.0 milestone Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants