mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: add test to ensure 8-byte alignment (#3948)
See 0af9e2b693
This commit is contained in:
parent
95f5d4780d
commit
48ee15ac42
1 changed files with 21 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
|
||||
)
|
||||
|
@ -24,6 +25,26 @@ func TestMarshalTimeseriesFast(t *testing.T) {
|
|||
if !reflect.DeepEqual(tss, tss2) {
|
||||
t.Fatalf("unexpected timeseries unmarshaled\ngot\n%#v\nwant\n%#v", tss2[0], tss[0])
|
||||
}
|
||||
|
||||
// Check 8-byte alignment.
|
||||
// This prevents from SIGBUS error on arm architectures.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/3927
|
||||
for _, ts := range tss2 {
|
||||
if len(ts.Values) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// check float64 alignment
|
||||
addr := uintptr(unsafe.Pointer(&ts.Values[0]))
|
||||
if mod := addr % unsafe.Alignof(ts.Values[0]); mod != 0 {
|
||||
t.Fatalf("mis-aligned; &ts.Values[0]=%p; mod=%d", &ts.Values[0], mod)
|
||||
}
|
||||
// check int64 alignment
|
||||
addr = uintptr(unsafe.Pointer(&ts.Timestamps[0]))
|
||||
if mod := addr % unsafe.Alignof(ts.Timestamps[0]); mod != 0 {
|
||||
t.Fatalf("mis-aligned; &ts.Timestamps[0]=%p; mod=%d", &ts.Timestamps[0], mod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Single series
|
||||
|
|
Loading…
Reference in a new issue