Comments (6)
ack there's something memory leak might be happening in host generated code, as I confirmed the following test code can succeed fast with tinygo test -target wasi ./...
.
var p TestPlugin
func Test_In_TinyGo(t *testing.T) {
ctx := context.Background()
const entrySize = 10000
// Initialize.
response, err := p.PassData(ctx, host.PassDataRequest{
Entries: entrySize,
Sequence: 0,
})
if err != nil {
t.Fatal(err)
}
if len(response.Data) != entrySize {
t.Fatalf("data size mismatch: %d != %d", len(response.Data), entrySize)
}
log.Printf("Size of data being passed %d (%d bytes)", len(response.Data), response.SizeVT())
for i := uint64(0); i < 20; i++ {
log.Printf("calling plugin %d", i)
start := time.Now()
response, err = p.PassData(context.Background(), host.PassDataRequest{
Sequence: i,
Entries: entrySize,
Data: response.Data,
})
log.Printf("call execution time: %s", time.Since(start))
if err != nil {
t.Error(err)
return
}
if len(response.Data) != int(entrySize) {
t.Errorf("expected %d entries, got %d", entrySize, len(response.Data))
return
}
}
}
from go-plugin.
well, the test case is not enough to simulate the behavior -- I have to copy the entire PassDataRequest
in each iteration. WIll fix it
from go-plugin.
Updated, though it's till finishing in a decent time vs go test --- PASS: TestPlugin_MemoryMedium (80.04s)
:
$ tinygo test -target wasi ./...
--snip--
ok github.com/cchamplin/plugin-bug/guest 9.114s
package main
import (
"context"
host "github.com/cchamplin/plugin-bug/plugin"
"log"
"strings"
"testing"
"time"
)
var p TestPlugin
func Test_In_TinyGo(t *testing.T) {
ctx := context.Background()
const entrySize = 10000
// Initialize.
response, err := p.PassData(ctx, host.PassDataRequest{
Entries: entrySize,
Sequence: 0,
})
if err != nil {
t.Fatal(err)
}
if len(response.Data) != entrySize {
t.Fatalf("data size mismatch: %d != %d", len(response.Data), entrySize)
}
log.Printf("Size of data being passed %d (%d bytes)", len(response.Data), response.SizeVT())
for i := uint64(0); i < 20; i++ {
log.Printf("calling plugin %d", i)
start := time.Now()
req := &host.PassDataRequest{
Sequence: i,
Entries: entrySize,
Data: make(map[string]*host.State, entrySize),
}
for k, v := range response.Data {
state := &host.State{
FieldA: strings.Clone(v.FieldA),
FieldB: strings.Clone(v.FieldB),
FieldC: strings.Clone(v.FieldC),
FieldD: strings.Clone(v.FieldD),
FieldE: strings.Clone(v.FieldE),
FieldF: strings.Clone(v.FieldF),
FieldG: strings.Clone(v.FieldG),
FieldH: strings.Clone(v.FieldH),
FieldI: strings.Clone(v.FieldI),
FieldJ: strings.Clone(v.FieldJ),
FieldK: strings.Clone(v.FieldK),
FieldL: strings.Clone(v.FieldL),
FieldM: strings.Clone(v.FieldM),
FieldN: strings.Clone(v.FieldN),
}
req.Data[k] = state
}
response, err = p.PassData(context.Background(), *req)
log.Printf("call execution time: %s", time.Since(start))
if err != nil {
t.Error(err)
return
}
if len(response.Data) != int(entrySize) {
t.Errorf("expected %d entries, got %d", entrySize, len(response.Data))
return
}
}
}
from go-plugin.
I am pretty confident that this is an TinyGo issue. Could you try https://github.com/wasilibs/nottinygc to see problems will be gone?
ref: tetratelabs/proxy-wasm-go-sdk#349 (comment)
from go-plugin.
Just stumbled across this, was wondering if anyone ever got this figured out @mathetake @cchamplin ?
Looking to use this library with Wazero in a data intensive application, with plugins written in TinyGo, but want to see if this got resolved.
from go-plugin.
@brennanjl because large amounts of data have to be re-serialized into protobuf each time, it will be difficult to support with this model I think.
First, really consider what @mathetake said because I have seen one project drop 1/2 its overhead by using https://github.com/wasilibs/nottinygc
After that, if you still have issues, I think the choices are..
- use this project, but make your own special host functions for the bulk data. (just the bulk is hard)
- use a raw ABI approach instead of this project. (everything is hard)
from go-plugin.
Related Issues (20)
- Errors returned from plugin are never surfaced to host HOT 9
- Removes context parameter from instruction-scoped operations HOT 3
- too many arguments in call to p.module.Memory().Size HOT 4
- Plugin seems to be closing. Saving plugins in a map and calling on functionality elsewhere HOT 3
- exposing filesystem from plugin to host HOT 2
- Is using values instead of pointers is by design? HOT 2
- Proposal: Utilize golang text template engine for generating plugin files HOT 2
- protoc-gen-go-plugin always generate it's hardcoded version HOT 2
- Cleanup *.pb.go files generated at previous generating stage
- Add option to plugin for generating additional application stubs
- Add golangci-lint step and fix linter issues
- After update: panic: free: invalid pointer HOT 7
- Allow using CompiledModule from previous call instead of loading from disk HOT 4
- Add loading plugins from binary HOT 3
- How can I get the plugin id before plugin loaded
- Gen calling code for non golang ?
- Plugin is not compiling with tinygo v0.29.0 HOT 2
- Can I use go1.21 to compile plugins?
- Missing proto `fieldmaskpb` package (for known types)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-plugin.