Bryan C. Mills
cf872fae78
expvar: make (*Map).Init clear existing keys
...
fixes #21619
Change-Id: I5bb513dfc8cac875b06a262eec40b5863ae23a4c
Reviewed-on: https://go-review.googlesource.com/62370
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-11 21:31:51 +00:00
Bryan C. Mills
e9702c0c85
expvar: reduce sync.Map overhead for (*Map).Set
...
Use Load instead of LoadOrStore in the fast path to save 1 alloc/op
for existing keys.
name old time/op new time/op delta
IntAdd 6.39ns ± 7% 6.97ns ±19% ~ (p=0.105 n=8+8)
IntAdd-6 12.3ns ± 1% 12.2ns ± 1% ~ (p=0.396 n=7+7)
IntSet 6.41ns ± 6% 6.94ns ±21% ~ (p=0.168 n=8+8)
IntSet-6 12.1ns ± 3% 11.7ns ± 9% ~ (p=0.496 n=7+8)
FloatAdd 14.3ns ± 9% 14.7ns ± 4% ~ (p=0.088 n=8+8)
FloatAdd-6 36.5ns ± 1% 36.6ns ± 0% ~ (p=0.709 n=7+6)
FloatSet 6.59ns ± 7% 6.47ns ± 7% ~ (p=0.397 n=8+7)
FloatSet-6 12.2ns ± 1% 12.2ns ± 2% ~ (p=0.748 n=7+7)
StringSet 67.8ns ± 6% 68.7ns ± 6% ~ (p=0.342 n=8+8)
StringSet-6 41.8ns ± 5% 41.7ns ± 5% ~ (p=0.979 n=8+8)
MapSet 294ns ± 6% 234ns ± 4% -20.35% (p=0.000 n=8+8)
MapSet-6 95.8ns ± 2% 89.4ns ± 3% -6.73% (p=0.000 n=8+8)
MapSetDifferent 1.31µs ± 5% 1.07µs ± 4% -18.21% (p=0.000 n=8+8)
MapSetDifferent-6 260ns ± 8% 210ns ± 9% -19.44% (p=0.000 n=8+8)
MapSetString 294ns ± 6% 236ns ± 4% -19.92% (p=0.000 n=8+8)
MapSetString-6 95.6ns ± 2% 89.9ns ± 2% -5.97% (p=0.000 n=7+8)
MapAddSame 1.46µs ± 3% 1.46µs ± 5% ~ (p=0.721 n=8+8)
MapAddSame-6 328ns ± 6% 330ns ± 4% ~ (p=0.776 n=8+8)
MapAddDifferent 4.89µs ± 7% 4.98µs ± 6% ~ (p=0.505 n=8+8)
MapAddDifferent-6 1.02µs ± 3% 1.01µs ± 4% ~ (p=0.352 n=7+8)
MapAddSameSteadyState 62.1ns ± 7% 60.8ns ± 4% ~ (p=0.521 n=8+8)
MapAddSameSteadyState-6 38.1ns ± 3% 37.7ns ± 0% ~ (p=0.185 n=7+6)
MapAddDifferentSteadyState 290ns ± 5% 293ns ± 4% ~ (p=0.515 n=8+8)
MapAddDifferentSteadyState-6 63.0ns ± 7% 63.7ns ±11% ~ (p=0.482 n=7+8)
RealworldExpvarUsage 7.39µs ± 5% 7.51µs ± 5% ~ (p=0.382 n=8+8)
RealworldExpvarUsage-6 3.07µs ±28% 3.04µs ±43% ~ (p=0.798 n=8+8)
name old alloc/op new alloc/op delta
IntAdd 0.00B 0.00B ~ (all equal)
IntAdd-6 0.00B 0.00B ~ (all equal)
IntSet 0.00B 0.00B ~ (all equal)
IntSet-6 0.00B 0.00B ~ (all equal)
FloatAdd 0.00B 0.00B ~ (all equal)
FloatAdd-6 0.00B 0.00B ~ (all equal)
FloatSet 0.00B 0.00B ~ (all equal)
FloatSet-6 0.00B 0.00B ~ (all equal)
StringSet 16.0B ± 0% 16.0B ± 0% ~ (all equal)
StringSet-6 16.0B ± 0% 16.0B ± 0% ~ (all equal)
MapSet 48.0B ± 0% 32.0B ± 0% -33.33% (p=0.000 n=8+8)
MapSet-6 48.0B ± 0% 32.0B ± 0% -33.33% (p=0.000 n=8+8)
MapSetDifferent 192B ± 0% 128B ± 0% -33.33% (p=0.000 n=8+8)
MapSetDifferent-6 192B ± 0% 128B ± 0% -33.33% (p=0.000 n=8+8)
MapSetString 48.0B ± 0% 32.0B ± 0% -33.33% (p=0.000 n=8+8)
MapSetString-6 48.0B ± 0% 32.0B ± 0% -33.33% (p=0.000 n=8+8)
MapAddSame 480B ± 0% 480B ± 0% ~ (all equal)
MapAddSame-6 480B ± 0% 480B ± 0% ~ (all equal)
MapAddDifferent 1.09kB ± 0% 1.09kB ± 0% ~ (all equal)
MapAddDifferent-6 1.09kB ± 0% 1.09kB ± 0% ~ (all equal)
MapAddSameSteadyState 0.00B 0.00B ~ (all equal)
MapAddSameSteadyState-6 0.00B 0.00B ~ (all equal)
MapAddDifferentSteadyState 0.00B 0.00B ~ (all equal)
MapAddDifferentSteadyState-6 0.00B 0.00B ~ (all equal)
RealworldExpvarUsage 0.00B 0.00B ~ (all equal)
RealworldExpvarUsage-6 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
IntAdd 0.00 0.00 ~ (all equal)
IntAdd-6 0.00 0.00 ~ (all equal)
IntSet 0.00 0.00 ~ (all equal)
IntSet-6 0.00 0.00 ~ (all equal)
FloatAdd 0.00 0.00 ~ (all equal)
FloatAdd-6 0.00 0.00 ~ (all equal)
FloatSet 0.00 0.00 ~ (all equal)
FloatSet-6 0.00 0.00 ~ (all equal)
StringSet 1.00 ± 0% 1.00 ± 0% ~ (all equal)
StringSet-6 1.00 ± 0% 1.00 ± 0% ~ (all equal)
MapSet 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=8+8)
MapSet-6 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=8+8)
MapSetDifferent 12.0 ± 0% 8.0 ± 0% -33.33% (p=0.000 n=8+8)
MapSetDifferent-6 12.0 ± 0% 8.0 ± 0% -33.33% (p=0.000 n=8+8)
MapSetString 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=8+8)
MapSetString-6 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=8+8)
MapAddSame 11.0 ± 0% 11.0 ± 0% ~ (all equal)
MapAddSame-6 11.0 ± 0% 11.0 ± 0% ~ (all equal)
MapAddDifferent 31.0 ± 0% 31.0 ± 0% ~ (all equal)
MapAddDifferent-6 31.0 ± 0% 31.0 ± 0% ~ (all equal)
MapAddSameSteadyState 0.00 0.00 ~ (all equal)
MapAddSameSteadyState-6 0.00 0.00 ~ (all equal)
MapAddDifferentSteadyState 0.00 0.00 ~ (all equal)
MapAddDifferentSteadyState-6 0.00 0.00 ~ (all equal)
RealworldExpvarUsage 0.00 0.00 ~ (all equal)
RealworldExpvarUsage-6 0.00 0.00 ~ (all equal)
https://perf.golang.org/search?q=upload:20170501.1
Change-Id: I28fc3906473f2b7307f6d1ae05a8d9b01ef8a6f8
Reviewed-on: https://go-review.googlesource.com/42211
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-02 17:13:40 +00:00
Bryan C. Mills
fb0fe4277d
expvar: replace RWMutex usage with sync.Map and atomics
...
Int and Float already used atomics.
When many goroutines on many CPUs concurrently update a StringSet or a
Map with different keys per goroutine, this change results in dramatic
steady-state speedups.
This change does add some overhead for single-CPU and ephemeral maps.
I believe that is mostly due to an increase in allocations per call
(to pack the map keys and values into interface{} values that may
escape into the heap). With better inlining and/or escape analysis,
the single-CPU penalty may decline somewhat.
There are still two RWMutexes in the package: one for the keys in the
global "vars" map, and one for the keys in individual Map variables.
Those RWMutexes could also be eliminated, but avoiding excessive
allocations when adding new keys would require care. The remaining
RWMutexes are only acquired in Do functions, which I believe are not
typically on the fast path.
updates #17973
updates #18177
name old time/op new time/op delta
StringSet 65.9ns ± 8% 55.7ns ± 1% -15.46% (p=0.000 n=8+7)
StringSet-6 416ns ±22% 127ns ±19% -69.37% (p=0.000 n=8+8)
StringSet-48 309ns ± 8% 94ns ± 3% -69.43% (p=0.001 n=7+7)
name old alloc/op new alloc/op delta
StringSet 0.00B 16.00B ± 0% +Inf% (p=0.000 n=8+8)
StringSet-6 0.00B 16.00B ± 0% +Inf% (p=0.000 n=8+8)
StringSet-48 0.00B 16.00B ± 0% +Inf% (p=0.000 n=8+8)
name old allocs/op new allocs/op delta
StringSet 0.00 1.00 ± 0% +Inf% (p=0.000 n=8+8)
StringSet-6 0.00 1.00 ± 0% +Inf% (p=0.000 n=8+8)
StringSet-48 0.00 1.00 ± 0% +Inf% (p=0.000 n=8+8)
https://perf.golang.org/search?q=upload:20170427.3
name old time/op new time/op delta
IntAdd 5.64ns ± 3% 5.58ns ± 1% ~ (p=0.185 n=8+8)
IntAdd-6 18.6ns ±32% 21.4ns ±21% ~ (p=0.078 n=8+8)
IntAdd-48 19.6ns ±13% 20.6ns ±19% ~ (p=0.702 n=8+8)
IntSet 5.50ns ± 1% 5.48ns ± 0% ~ (p=0.222 n=7+8)
IntSet-6 18.5ns ±16% 20.4ns ±30% ~ (p=0.314 n=8+8)
IntSet-48 19.7ns ±12% 20.4ns ±16% ~ (p=0.522 n=8+8)
FloatAdd 14.5ns ± 1% 14.6ns ± 2% ~ (p=0.237 n=7+8)
FloatAdd-6 69.9ns ±13% 68.4ns ± 7% ~ (p=0.557 n=7+7)
FloatAdd-48 110ns ± 9% 109ns ± 6% ~ (p=0.667 n=8+8)
FloatSet 7.62ns ± 3% 7.64ns ± 5% ~ (p=0.939 n=8+8)
FloatSet-6 20.7ns ±22% 21.0ns ±23% ~ (p=0.959 n=8+8)
FloatSet-48 20.4ns ±24% 20.8ns ±19% ~ (p=0.899 n=8+8)
MapSet 88.1ns ±15% 200.9ns ± 7% +128.11% (p=0.000 n=8+8)
MapSet-6 453ns ±12% 202ns ± 8% -55.43% (p=0.000 n=8+8)
MapSet-48 432ns ±12% 240ns ±15% -44.49% (p=0.000 n=8+8)
MapSetDifferent 349ns ± 1% 876ns ± 2% +151.08% (p=0.001 n=6+7)
MapSetDifferent-6 1.74µs ±32% 0.25µs ±17% -85.71% (p=0.000 n=8+8)
MapSetDifferent-48 1.77µs ±10% 0.14µs ± 2% -91.84% (p=0.000 n=8+8)
MapSetString 88.1ns ± 7% 205.3ns ± 5% +132.98% (p=0.001 n=7+7)
MapSetString-6 438ns ±30% 205ns ± 9% -53.15% (p=0.000 n=8+8)
MapSetString-48 419ns ±14% 241ns ±15% -42.39% (p=0.000 n=8+8)
MapAddSame 686ns ± 9% 1010ns ± 5% +47.41% (p=0.000 n=8+8)
MapAddSame-6 238ns ±10% 300ns ±11% +26.22% (p=0.000 n=8+8)
MapAddSame-48 366ns ± 4% 483ns ± 3% +32.06% (p=0.000 n=8+8)
MapAddDifferent 1.96µs ± 4% 3.24µs ± 6% +65.58% (p=0.000 n=8+8)
MapAddDifferent-6 553ns ± 3% 948ns ± 8% +71.43% (p=0.000 n=7+8)
MapAddDifferent-48 548ns ± 4% 1242ns ±10% +126.81% (p=0.000 n=8+8)
MapAddSameSteadyState 31.5ns ± 7% 41.7ns ± 6% +32.61% (p=0.000 n=8+8)
MapAddSameSteadyState-6 239ns ± 7% 101ns ±30% -57.53% (p=0.000 n=7+8)
MapAddSameSteadyState-48 152ns ± 4% 85ns ±13% -43.84% (p=0.000 n=8+7)
MapAddDifferentSteadyState 151ns ± 5% 177ns ± 1% +17.32% (p=0.001 n=8+6)
MapAddDifferentSteadyState-6 861ns ±15% 62ns ±23% -92.85% (p=0.000 n=8+8)
MapAddDifferentSteadyState-48 617ns ± 2% 20ns ±14% -96.75% (p=0.000 n=8+8)
RealworldExpvarUsage 4.33µs ± 4% 4.48µs ± 6% ~ (p=0.336 n=8+7)
RealworldExpvarUsage-6 2.12µs ±20% 2.28µs ±10% ~ (p=0.228 n=8+6)
RealworldExpvarUsage-48 1.23µs ±19% 1.36µs ±16% ~ (p=0.152 n=7+8)
name old alloc/op new alloc/op delta
IntAdd 0.00B 0.00B ~ (all equal)
IntAdd-6 0.00B 0.00B ~ (all equal)
IntAdd-48 0.00B 0.00B ~ (all equal)
IntSet 0.00B 0.00B ~ (all equal)
IntSet-6 0.00B 0.00B ~ (all equal)
IntSet-48 0.00B 0.00B ~ (all equal)
FloatAdd 0.00B 0.00B ~ (all equal)
FloatAdd-6 0.00B 0.00B ~ (all equal)
FloatAdd-48 0.00B 0.00B ~ (all equal)
FloatSet 0.00B 0.00B ~ (all equal)
FloatSet-6 0.00B 0.00B ~ (all equal)
FloatSet-48 0.00B 0.00B ~ (all equal)
MapSet 0.00B 48.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSet-6 0.00B 48.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSet-48 0.00B 48.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSetDifferent 0.00B 192.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSetDifferent-6 0.00B 192.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSetDifferent-48 0.00B 192.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSetString 0.00B 48.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSetString-6 0.00B 48.00B ± 0% +Inf% (p=0.000 n=8+8)
MapSetString-48 0.00B 48.00B ± 0% +Inf% (p=0.000 n=8+8)
MapAddSame 456B ± 0% 480B ± 0% +5.26% (p=0.000 n=8+8)
MapAddSame-6 456B ± 0% 480B ± 0% +5.26% (p=0.000 n=8+8)
MapAddSame-48 456B ± 0% 480B ± 0% +5.26% (p=0.000 n=8+8)
MapAddDifferent 672B ± 0% 1088B ± 0% +61.90% (p=0.000 n=8+8)
MapAddDifferent-6 672B ± 0% 1088B ± 0% +61.90% (p=0.000 n=8+8)
MapAddDifferent-48 672B ± 0% 1088B ± 0% +61.90% (p=0.000 n=8+8)
MapAddSameSteadyState 0.00B 0.00B ~ (all equal)
MapAddSameSteadyState-6 0.00B 0.00B ~ (all equal)
MapAddSameSteadyState-48 0.00B 0.00B ~ (all equal)
MapAddDifferentSteadyState 0.00B 0.00B ~ (all equal)
MapAddDifferentSteadyState-6 0.00B 0.00B ~ (all equal)
MapAddDifferentSteadyState-48 0.00B 0.00B ~ (all equal)
RealworldExpvarUsage 0.00B 0.00B ~ (all equal)
RealworldExpvarUsage-6 0.00B 0.00B ~ (all equal)
RealworldExpvarUsage-48 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
IntAdd 0.00 0.00 ~ (all equal)
IntAdd-6 0.00 0.00 ~ (all equal)
IntAdd-48 0.00 0.00 ~ (all equal)
IntSet 0.00 0.00 ~ (all equal)
IntSet-6 0.00 0.00 ~ (all equal)
IntSet-48 0.00 0.00 ~ (all equal)
FloatAdd 0.00 0.00 ~ (all equal)
FloatAdd-6 0.00 0.00 ~ (all equal)
FloatAdd-48 0.00 0.00 ~ (all equal)
FloatSet 0.00 0.00 ~ (all equal)
FloatSet-6 0.00 0.00 ~ (all equal)
FloatSet-48 0.00 0.00 ~ (all equal)
MapSet 0.00 3.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSet-6 0.00 3.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSet-48 0.00 3.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSetDifferent 0.00 12.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSetDifferent-6 0.00 12.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSetDifferent-48 0.00 12.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSetString 0.00 3.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSetString-6 0.00 3.00 ± 0% +Inf% (p=0.000 n=8+8)
MapSetString-48 0.00 3.00 ± 0% +Inf% (p=0.000 n=8+8)
MapAddSame 6.00 ± 0% 11.00 ± 0% +83.33% (p=0.000 n=8+8)
MapAddSame-6 6.00 ± 0% 11.00 ± 0% +83.33% (p=0.000 n=8+8)
MapAddSame-48 6.00 ± 0% 11.00 ± 0% +83.33% (p=0.000 n=8+8)
MapAddDifferent 14.0 ± 0% 31.0 ± 0% +121.43% (p=0.000 n=8+8)
MapAddDifferent-6 14.0 ± 0% 31.0 ± 0% +121.43% (p=0.000 n=8+8)
MapAddDifferent-48 14.0 ± 0% 31.0 ± 0% +121.43% (p=0.000 n=8+8)
MapAddSameSteadyState 0.00 0.00 ~ (all equal)
MapAddSameSteadyState-6 0.00 0.00 ~ (all equal)
MapAddSameSteadyState-48 0.00 0.00 ~ (all equal)
MapAddDifferentSteadyState 0.00 0.00 ~ (all equal)
MapAddDifferentSteadyState-6 0.00 0.00 ~ (all equal)
MapAddDifferentSteadyState-48 0.00 0.00 ~ (all equal)
RealworldExpvarUsage 0.00 0.00 ~ (all equal)
RealworldExpvarUsage-6 0.00 0.00 ~ (all equal)
RealworldExpvarUsage-48 0.00 0.00 ~ (all equal)
https://perf.golang.org/search?q=upload:20170427.1
Change-Id: I388b2e8a3cadb84fc1418af8acfc27338f799273
Reviewed-on: https://go-review.googlesource.com/41930
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 21:59:55 +00:00
Bryan C. Mills
7e036521d5
expvar: add benchmark for (*Map).Set with per-goroutine keys
...
Change-Id: I0fa68ca9812fe5e82ffb9d0b9598e95b47183eb8
Reviewed-on: https://go-review.googlesource.com/38011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-10 19:09:48 +00:00
Bryan C. Mills
7ffdb75775
expvar: add benchmarks for steady-state Map Add calls
...
Add a benchmark for setting a String value, which we may
want to treat differently from Int or Float due to the need to support
Add methods for the latter.
Update tests to use only the exported API instead of making (fragile)
assumptions about unexported fields.
The existing Map benchmarks construct a new Map for each iteration, which
focuses the benchmark results on the initial allocation costs for the
Map and its entries. This change adds variants of the benchmarks which
use a long-lived map in order to measure steady-state performance for
Map updates on existing keys.
Updates #18177
Change-Id: I62c920991d17d5898c592446af382cd5c04c528a
Reviewed-on: https://go-review.googlesource.com/36959
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-14 22:11:35 +00:00
Bryan C. Mills
aa15387996
expvar: make BenchmarkAdd{Same,Different} comparable to 1.8
...
bradfitz noted in change 36717 that the new behavior was no longer
comparable with the old. This change restores comparable behavior
for -cpu=1.
BenchmarkMapAddSame 909 909 +0.00%
BenchmarkMapAddSame-6 1309 262 -79.98%
BenchmarkMapAddDifferent 2856 3030 +6.09%
BenchmarkMapAddDifferent-6 3803 581 -84.72%
updates #18177
Change-Id: Ifaff5a1f48be92002d86c296220313b7efdc81d6
Reviewed-on: https://go-review.googlesource.com/36723
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-10 20:08:14 +00:00
Bryan C. Mills
39651bb50b
expvar: parallelize BenchmarkMapAdd{Same,Different}
...
The other expvar tests are already parallelized, and this will help to
measure the impact of potential implementations for #18177 .
updates #18177
Change-Id: I0f4f1a16a0285556cbcc8339855b6459af412675
Reviewed-on: https://go-review.googlesource.com/36717
Reviewed-by: Russ Cox <rsc@golang.org>
2017-02-10 17:37:14 +00:00
Filippo Valsorda
714318be88
expvar: add Value methods
...
Closes #15815
Change-Id: I08154dbff416198cf7787e446b1e00e62c03a972
Reviewed-on: https://go-review.googlesource.com/30917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 21:39:03 +00:00
Anders Pearson
6ba5b32922
expvar: export http.Handler
...
Add a method to expose the handler to allow it to be installed at a
non-standard location or used with a different ServeMux.
fixes #15030
Change-Id: If778ad6fcc200f124a05c0a493511e364fca6078
Reviewed-on: https://go-review.googlesource.com/24722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-25 23:34:28 +00:00
Scott Bell
2a12035f8e
expvar: slightly expand documentation for Var's String method
...
Fixes #15088 .
Change-Id: I7727829a4062e15c0e5e3beff4d0bfc1fa327b0f
Reviewed-on: https://go-review.googlesource.com/23232
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-19 04:20:47 +00:00
David Symonds
6f2a8810b0
expvar: Ensure strings are written as valid JSON.
...
Change-Id: I5147dbf4e85cf42cd1f32c57861e4c16d9dbd049
Reviewed-on: https://go-review.googlesource.com/21529
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-06 03:52:39 +00:00
David Symonds
e8f01e5cae
expvar: document that the Var interface's String method should return a valid JSON value.
...
Change-Id: If4e740f3dbef4053355542eebdd899b3099d872c
Reviewed-on: https://go-review.googlesource.com/21525
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-05 05:50:56 +00:00
Brad Fitzpatrick
5fea2ccc77
all: single space after period.
...
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions. This means contributors won't be confused by
misleading precedence.
This CL doesn't use go/doc to parse. It only addresses // comments.
It was generated with:
$ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])')
$ go test go/doc -update
Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
Reviewed-on: https://go-review.googlesource.com/20022
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 00:13:47 +00:00
Rick Arnold
5abd327d00
expvar: document that Get returns nil for non-existent vars
...
Also added a test to ensure the behavior.
Fixes #14150
Change-Id: Ib3ee9fdae59826fa594ce1be3c49b51d740b56eb
Reviewed-on: https://go-review.googlesource.com/19915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 16:48:08 +00:00
Matt T. Proud
926616da3f
expvar: swap Float sync. from mutex to atomic.
...
Float type from a mutex to atomic bit array in a manner akin to
Google Guava's AtomicDouble[0], including adding a benchmark for the
type (benchcmp included below) along with some expvar_test.go cruft
being fixed.
benchmark old ns/op new ns/op delta
BenchmarkFloatSet 115 9.37 -91.85%
BenchmarkFloatAdd 114 17.1 -85.00%
benchmark old allocs new allocs delta
BenchmarkFloatSet 0 0 +0.00%
BenchmarkFloatAdd 0 0 +0.00%
benchmark old bytes new bytes delta
BenchmarkFloatSet 0 0 +0.00%
BenchmarkFloatAdd 0 0 +0.00%
[0] - http://goo.gl/m4dtlI
Change-Id: I4ce6a913734ec692e3ed243f6e6f7c11da4c6036
Reviewed-on: https://go-review.googlesource.com/3687
Reviewed-by: Rob Pike <r@golang.org>
2015-04-12 23:07:50 +00:00
Dmitry Vyukov
08ca401444
expvar: fix build
...
Change-Id: I6ee7aa76673e51576b5a84c512b22a0f8af5b02f
Reviewed-on: https://go-review.googlesource.com/3966
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-02-05 13:53:29 +00:00
Evan Phoenix
fc22fb8f0c
expvar: Add benchmarks for perf sensitive operations
...
These benchmarks are only for functions commonly used in loops. The
other functions are typically used for inspection or setup and thus are
not performance sensitive.
Change-Id: I8d0a0ba2d8234ecacb40fa3aa9077bf93c8fe89c
Reviewed-on: https://go-review.googlesource.com/3680
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-02-05 13:32:25 +00:00
Evan Phoenix
bd043d8629
expvar: Use sync/atomic to manipulate Int for better perf
...
Using a mutex to protect a single int operation is quite heavyweight.
Using sync/atomic provides much better performance. This change was
benchmarked as such:
BenchmarkSync 10000000 139 ns/op
BenchmarkAtomic 200000000 9.90 ns/op
package blah
import (
"sync"
"sync/atomic"
"testing"
)
type Int struct {
mu sync.RWMutex
i int64
}
func (v *Int) Add(delta int64) {
v.mu.Lock()
defer v.mu.Unlock()
v.i += delta
}
type AtomicInt struct {
i int64
}
func (v *AtomicInt) Add(delta int64) {
atomic.AddInt64(&v.i, delta)
}
func BenchmarkSync(b *testing.B) {
s := new(Int)
for i := 0; i < b.N; i++ {
s.Add(1)
}
}
func BenchmarkAtomic(b *testing.B) {
s := new(AtomicInt)
for i := 0; i < b.N; i++ {
s.Add(1)
}
}
Change-Id: I6998239c785967647351bbfe8533c38e4894543b
Reviewed-on: https://go-review.googlesource.com/3430
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-01-29 08:24:00 +00:00
Russ Cox
c007ce824d
build: move package sources from src/pkg to src
...
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
2014-09-08 00:08:51 -04:00