Use strings.Replacer instead of hand-rolled escapeString#48
Merged
fabxc merged 1 commit intoprometheus:masterfrom Jul 26, 2016
lmb:fix-escapestring
Merged
Use strings.Replacer instead of hand-rolled escapeString#48fabxc merged 1 commit intoprometheus:masterfrom lmb:fix-escapestring
fabxc merged 1 commit intoprometheus:masterfrom
lmb:fix-escapestring
Conversation
expfmt/text_create.go
Outdated
| default: | ||
| result.WriteRune(c) | ||
| } | ||
| r := escapeReplacer |
Contributor
There was a problem hiding this comment.
Do we need this variable?
Contributor
There was a problem hiding this comment.
We can just directly call escapeReplacer.Replace(v) etc.
Contributor
|
Thanks, should be good after comment. |
This reduces run-time (since replacement is done via table lookup) and memory consumption (since strings that do not need replacing are returned as they are).
name old time/op new time/op delta
Create-4 66.9µs ± 3% 55.0µs ±12% -17.82% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
Create-4 19.2kB ± 0% 13.7kB ± 0% -28.44% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
Create-4 617 ± 0% 498 ± 0% -19.29% (p=0.008 n=5+5)
Contributor
Author
|
Yup, done. |
Merged
Contributor
|
Thank you 👍 |
gouthamve
pushed a commit
to gouthamve/common
that referenced
this pull request
Jul 22, 2018
Motivating example is to not excessively log the same http 4xx code over and over from the same ip, as this doesn't add info and bloats our log volume. This requires some abuse of logrus to work, but we do this via a formatter which can either emit the original message, or the empty string to log no message (this is harmless). Later, a seperate goroutine will emit a new log that logs the original log and how many times it occurred. We always log the first time we see a given message, then start a timer. If we see the message again at least once in that time frame, we log at the end of the time frame how many times. Note this means we can say "repeated once", which is a little confusing but preferable to displaying the original message unchanged but time delayed, which can be very misleading as there's no indication of the time delay.
alanprot
pushed a commit
to alanprot/common
that referenced
this pull request
Mar 15, 2023
…)" This reverts commit a23f449. It has never de-duplicated a single line for us in production.
alanprot
pushed a commit
to alanprot/common
that referenced
this pull request
Mar 15, 2023
Revert "logging: Add ability to deduplicate log messages (prometheus#48)"
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reduces run-time (since replacement is done via table lookup) and memory consumption (since strings that do not need replacing are returned as they are).