Skip to content

Commit

Permalink
K6 fixes (#379)
Browse files Browse the repository at this point in the history
* #fix: memory consumption of wasm parts

* #fix: slow gc issue
  • Loading branch information
akvlad authored Nov 7, 2023
1 parent 07357bf commit 6b36ff1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion wasm_parts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var eng *promql.Engine = nil
var engC = 0

func getEng() *promql.Engine {
if eng == nil || engC >= 5 {
if eng == nil || engC > 5 {
eng = promql.NewEngine(promql.EngineOpts{
Logger: TestLogger{},
MaxSamples: 100000,
Expand Down
27 changes: 15 additions & 12 deletions wasm_parts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@ class WasmError extends Error {}
module.exports.WasmError = WasmError

let counter = 0
var go = new Go();

const getWasm = (() => {
let wasm = null;
let cnt = 0;
let run = false;
const _Go = Go
var go = new _Go();
let wasm = null
let cnt = 0
let run = false
async function init () {
run = true;
go = new _Go();
run = true
const _wasm = await WebAssembly.instantiate(
gunzipSync(fs.readFileSync(WASM_URL)), go.importObject)
gunzipSync(fs.readFileSync(WASM_URL)), go.importObject)
go.run(_wasm.instance)
wasm = _wasm.instance
cnt = 0
run = false;
run = false
}
init();
init()
return () => {
if (cnt > 5 && !run){
init();
}
return wasm
if (cnt >= 20 && !run) {
init()
}
cnt++
return wasm
}
})()

const newId = () => {
Expand Down
Binary file modified wasm_parts/main.wasm.gz
Binary file not shown.

0 comments on commit 6b36ff1

Please sign in to comment.