swim: cache decoded payload in the Lua module
Users of Lua SWIM module likely will use Lua objects as a payload. Lua objects are serialized into MessagePack automatically, and deserialized back on other instances. But deserialization of 1.2Kb payload on each member:payload() invocation is quite heavy operation. This commit caches decoded payloads to return them again until change. A microbenchmark showed, that cached payload is returned ~100 times faster, than it is decoded each time. Even though a tested payload was quite small and simple: s:set_payload({a = 100, b = 200}) Even this payload is returned 100 times faster, and does not affect GC. Part of #3234
Showing
- extra/exports 1 addition, 0 deletionsextra/exports
- src/lib/swim/swim.c 6 additions, 0 deletionssrc/lib/swim/swim.c
- src/lib/swim/swim.h 12 additions, 0 deletionssrc/lib/swim/swim.h
- src/lua/swim.lua 31 additions, 8 deletionssrc/lua/swim.lua
- test/swim/swim.result 113 additions, 0 deletionstest/swim/swim.result
- test/swim/swim.test.lua 45 additions, 0 deletionstest/swim/swim.test.lua
Loading
Please register or sign in to comment