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

Frohman
Prole
Posts: 21
Joined: Sat Dec 08, 2012 12:32 pm

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

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)?

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

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.

trelemar
Prole
Posts: 22
Joined: Fri Dec 16, 2016 12:21 pm

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

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!

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

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.

trelemar
Prole
Posts: 22
Joined: Fri Dec 16, 2016 12:21 pm

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

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: 144
Joined: Mon Aug 29, 2016 8:51 am

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

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
Prole
Posts: 15
Joined: Sun Sep 24, 2017 10:02 am
Contact:

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

Daft punk??

Code: Select all

A = 1
If(A==1) then
Text = 'ok'
else
Text = 'all ok... wait.... WHAT?!'
end
love.graphics.print(text)


### Who is online

Users browsing this forum: No registered users and 9 guests