1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
From: Vincent Bernat <bernat@luffy.cx>
Date: Sat, 25 Jan 2014 13:42:47 +0100
Subject: [PATCH] ewma: ensure 64-bit alignment of uncounted
Forwarded: https://github.com/rcrowley/go-metrics/pull/37
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=736204
This bug was already fixed by #20 (and reported in #19) but was rolled
back after merging #17.
`uncounted` has been moved to top with a comment explaining that it
should stay at top. This is not mandatory but this is the easiest way to
ensure a good alignment in the future without taking too much care.
This alignment is required to use atomic functions as explained here:
http://godoc.org/sync/atomic#pkg-note-bug
---
ewma.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ewma.go b/ewma.go
index 8e22a7173de2..7c152a174a03 100644
--- a/ewma.go
+++ b/ewma.go
@@ -77,11 +77,11 @@ func (NilEWMA) Update(n int64) {}
// of uncounted events and processes them on each tick. It uses the
// sync/atomic package to manage uncounted events.
type StandardEWMA struct {
+ uncounted int64 // /!\ this should be the first member to ensure 64-bit alignment
alpha float64
+ rate float64
init bool
mutex sync.Mutex
- rate float64
- uncounted int64
}
// Rate returns the moving average rate of events per second.
--
1.8.5.3
|