Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micro gc #475

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions wasm_parts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand All @@ -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
}

Expand All @@ -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
Expand Down
10 changes: 0 additions & 10 deletions wasm_parts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -41,8 +33,6 @@ const getWasm = (() => {
}]
})
)
cnt = 0
run = false
}
init()
return () => {
Expand Down
Binary file modified wasm_parts/main.wasm.gz
Binary file not shown.
Loading