bitser: faster, harder, better serialization with LuaJIT

Showcase your libraries, tools and other projects that help your fellow love users.
Frohman
Prole
Posts: 21
Joined: Sat Dec 08, 2012 12:32 pm

Re: bitser: faster, harder, better serialization with LuaJIT

Post by Frohman »

Looks interesting! I'll have to compare performance to msgpack. Does it build up some kind of schema internally? Could totally make use of that for some sexy delta encoding.

How does it handle tables of class instances (tables)?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: bitser: faster, harder, better serialization with LuaJIT

Post by Robin »

bitser now re-uses its internal buffer, decimating overhead for repeated serialization/deserialization
Frohman wrote:I'll have to compare performance to msgpack.
The repo includes a main.lua which is a benchmark framework to compare bitser to other serializers, including lua-MessagePack. I think you'll find that bitser tends to be roughly comparable to it, but if your data isn't a tree (so tables used in multiple places, or cycles) lua-MessagePack is not built for it so bitser has a huge advantage.
Frohman wrote:Does it build up some kind of schema internally?
Nope, it writes out everything as-is.
Frohman wrote:How does it handle tables of class instances (tables)?
When dumping, it looks for tell-tale signs of several class libraries, and writes out the name of the class as a string plus the instance variables as a table. When loading, it looks up the class name in the class registry and constructs an instance without calling the initializer.
Help us help you: attach a .love.
trelemar
Prole
Posts: 22
Joined: Fri Dec 16, 2016 12:21 pm

Re: bitser: faster, harder, better serialization with LuaJIT

Post by trelemar »

Sorry to bump this thread... But the author still updates it on GitHub so I figured it's worth a shot!

How would I go about serializing a table that contains ImageData? Is that what the "register" function is for? I'd like to have bitser automatically call ImageData:getString() when serializing a table with ImageData in it. Thanks in advance!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: bitser: faster, harder, better serialization with LuaJIT

Post by Robin »

For static ImageData, you would use register(), yes.

If you're, say, writing a paint clone, or anything else where ImageData are created and manipulated at runtime, you would need to massage the data manually.
Help us help you: attach a .love.
trelemar
Prole
Posts: 22
Joined: Fri Dec 16, 2016 12:21 pm

Re: bitser: faster, harder, better serialization with LuaJIT

Post by trelemar »

Thanks for the reply. I ended up converting the imagedata to a string then serializing the string. Then when you load the serialized data it converts it back to imagedata.
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: bitser: faster, harder, better serialization with LuaJIT

Post by KayleMaster »

If the buffer is too small at line 247 (It's currently at a fixed size of 4096), the game will crash silently (no error messages, no love.quit trigger).
Took me a while to figure out. I doubled the buffer size to Buffer_makeBuffer(8192) and now it works fine (for me).
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

Re: bitser: faster, harder, better serialization with LuaJIT

Post by Darlex »

Daft punk??
Hi! I wish you have an amazing day!
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests