diff --git a/wasm_parts/main.go b/wasm_parts/main.go index 529119f7..e0e44304 100644 --- a/wasm_parts/main.go +++ b/wasm_parts/main.go @@ -21,11 +21,6 @@ import ( "wasm_parts/types" ) -//go:linkname get sync.(*Pool).Get -func get(p *sync.Pool) any { - panic("GET POOL") -} - var maxSamples = 5000000 type ctx struct { @@ -445,11 +440,12 @@ type TestSeries struct { data []byte stepMs int64 - labels labels.Labels - tsMs int64 - generatedMs int64 - val float64 - i int + labels labels.Labels + tsMs int64 + val float64 + i int + + state int } func (t *TestSeries) reset() { @@ -462,23 +458,21 @@ func (t *TestSeries) reset() { func (t *TestSeries) Next() bool { if t.i*16 >= len(t.data) { - if t.generatedMs == 0 { - t.tsMs += t.stepMs - t.generatedMs += t.stepMs - return true - } return false } ts := *(*int64)(unsafe.Pointer(&t.data[t.i*16])) - if ts-t.tsMs > t.stepMs && t.generatedMs < 300000 { + if t.state == 1 { t.tsMs += t.stepMs - t.generatedMs += t.stepMs - return true + if t.tsMs >= ts { + t.state = 0 + } + } + if t.state == 0 { + t.tsMs = ts + t.val = *(*float64)(unsafe.Pointer(&t.data[t.i*16+8])) + t.i++ + t.state = 1 } - t.tsMs = ts - t.generatedMs = 0 - t.val = *(*float64)(unsafe.Pointer(&t.data[t.i*16+8])) - t.i++ return true } @@ -496,7 +490,7 @@ func (t *TestSeries) Seek(tmMS int64) bool { if t.i < 0 { t.i = 0 } - t.tsMs = tmMS + t.tsMs = ms t.val = *(*float64)(unsafe.Pointer(&t.data[t.i*16+8])) t.i++ return true diff --git a/wasm_parts/main.js b/wasm_parts/main.js index 2d18d0d5..bd15ac79 100644 --- a/wasm_parts/main.js +++ b/wasm_parts/main.js @@ -13,18 +13,10 @@ const getWasm = (() => { const _Go = Go var go = new _Go(); let wasm = null - let cnt = 0 - let run = false - let int async function init () { go = new _Go(); - run = true const _wasm = await WebAssembly.instantiate( gunzipSync(fs.readFileSync(WASM_URL)), go.importObject) - int && clearInterval(int) - int = setInterval(() => { - console.log(`WASM SIZE: ${Math.floor(wasm.exports.memory.buffer.byteLength / 1024 / 1024)} MB`) - }, 5000) go.run(_wasm.instance) wasm = _wasm.instance wasm.exports.setMaxSamples(process.env.ADVANCED_PROMETHEUS_MAX_SAMPLES || 5000000) @@ -41,8 +33,6 @@ const getWasm = (() => { }] }) ) - cnt = 0 - run = false } init() return () => { diff --git a/wasm_parts/main.wasm.gz b/wasm_parts/main.wasm.gz index 4b1bb653..115f57b5 100644 Binary files a/wasm_parts/main.wasm.gz and b/wasm_parts/main.wasm.gz differ