GrabYonghao HuProblem & solution
2.3x faster using the Go plugin to replace Lua virtual machine
Summary
Talaria, an open-source distributed time-series database developed at Grab, previously allowed users to run custom data transformation scripts during ingestion using a Lua virtual machine. Launching and executing Lua scripts caused significant performance overhead when processing large volumes of events. To resolve this bottleneck, the team replaced the Lua VM with Go plugins compiled as Linux shared libraries (.so files). Benchmarks revealed that calling Go plugins achieves performance on par with native Go functions, executing roughly 2.3 times faster and consuming 2.3 times less memory than cached Lua VMs. Both execution methods conform to a unified Handler interface to load and run custom transformations.
Context
Executing custom data processing scripts via Lua virtual machines during high-volume event ingestion introduced significant performance and memory overhead in Talaria.
Approach / What changed
Replaced Lua VM execution with Go plugins compiled into Linux shared libraries (.so files) implementing a common Handler interface.
Takeaways
Go plugin calls perform almost identically to native Go functions, running approximately 2.3 times faster and using 2.3 times less memory than cached Lua VM executions.
Go plugins are compiled using the -buildmode=plugin flag, loaded via plugin.Open, and mapped to execution targets with the Lookup method.
The Go version used to compile a plugin must precisely match the Go version of the host application, which can be managed using Docker builds.
Source and freshness
- Source
- engineering.grab.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.