Closed ncruces closed 7 months ago
The test passes on arm64, both on an M1 macOS, and QEMU Linux: https://github.com/ncruces/go-sqlite3/actions/runs/7957530580
A few random notes:
Trace before sqlite3_prepare_v3
makes no sense.
go-sqlite3.(*Conn).PrepareFlags
calls sqlite3_prepare_v3
directly, and the test doesn't involve virtual tables (sqlite3_vtab_config_go
is virtual table API, env.go_cur_rowid
is a virtual table callback). These are different between macOS and Linux, but consistent (always the same on macOS, always the same on Linux, even across different machines).
I don't see anything specific about this code path. All I can say is involves goroutines (not WASM threads), and callbacks. Each goroutine shares the runtime, compiled module and host module, but has a different instantiated module. The host callbacks contend on some locks that protect host memory. The instantiated modules and their memories are not shared, not accessed across goroutines.
Here is the failing test: https://github.com/ncruces/go-sqlite3/blob/e02c5b5db04fad6a839cb6e3f81141347dd18f1a/tests/parallel/parallel_test.go#L35-L46
The bulk of it is testParallel
. This will run 5000 goroutines (with a limit of 6 concurrent goroutines): 12.5% writers and 87.5% readers. The database is held in memory, using the virtual file-system mechanism of SQLite.
https://github.com/tetratelabs/wazero/commit/8caae04aeae2089a327d27f5a87827f5f35ff09e seems to fix this, but has some incompatible API changes, so this needs to wait for a release.
Even then I may not change the default compiler: users can do so by editing sqlite3.RuntimeConfig
. Once released, I may add some explicit tests to ensure it keeps working, though.
Everything works with wazevo as the default compiler. Ready for release.
This fails very consistently after updating wazero to the optimizing compiler.
On:
On:
On: