From 2195bb66f7d04cee8848b6829a710a033cc68e39 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Wed, 3 May 2017 20:32:50 +0100 Subject: [PATCH] Ensure ewma int64s are always aligned. (#2675) --- storage/remote/ewma.go | 6 ++++-- storage/remote/queue_manager.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/storage/remote/ewma.go b/storage/remote/ewma.go index d974bc3bb..82b6dd101 100644 --- a/storage/remote/ewma.go +++ b/storage/remote/ewma.go @@ -29,8 +29,10 @@ type ewmaRate struct { mutex sync.Mutex } -func newEWMARate(alpha float64, interval time.Duration) ewmaRate { - return ewmaRate{ +// newEWMARate always allocates a new ewmaRate, as this guarantees the atomically +// accessed int64 will be aligned on ARM. See prometheus#2666. +func newEWMARate(alpha float64, interval time.Duration) *ewmaRate { + return &ewmaRate{ alpha: alpha, interval: interval, } diff --git a/storage/remote/queue_manager.go b/storage/remote/queue_manager.go index ad462d176..6813566a4 100644 --- a/storage/remote/queue_manager.go +++ b/storage/remote/queue_manager.go @@ -185,7 +185,7 @@ type QueueManager struct { quit chan struct{} wg sync.WaitGroup - samplesIn, samplesOut, samplesOutDuration ewmaRate + samplesIn, samplesOut, samplesOutDuration *ewmaRate integralAccumulator float64 }