The Super Optimized Serialization Data Format (SOSDF) V1 is a data format that saves Instances (such as parts) in a super compact way, it’s not designed to save a small amount of Instances (<100) efficiently, but it shows it’s strength when serializing thousands of Instances. I’ve made multiple serialization formats in the past just to try and improve them, and this is my best one so far, all the Instances are saved in a buffer (binary) that you can save to datastore!
“1-3+ bytes” will be equal to the bytesize
of that specific ID set in JSON settings,
for example if there’s less than 255 instances,
then the instance ID bytesize will be 1.
Null bytes use the same bytesize as the ID
corresponding to the section it ends, so null
bytes at the end of Enum IDs use same bytesize as
Enum IDs
“1 or 4 bytes” will change depending on
string length, string with <255 chars will
use 1 byte for stringlen, if the stringlen
is >254 then first byte of the stringlen
will be 255 and the next 3 will be the string
length as uint24
Benchmarks (on my crappy unoptimized serializer/deserializer version of this data format):
Crossroads map (4354 Instances):
Size: 60.1KB
Serialization Time: 0.05312660000345204 (53ms)
Deserialization TIme: 0.08800190000329167 (88ms) (Crossroads getting serialized, deleted then deserialized, no detail lost)
studio’s render distance is buggy
Treehouse (323 Instances):
Size: 5.6KB
Serialization Time: 0.007315299997571856 (7ms)
Deserialization TIme: 0.011207600007764995 (11ms) (Treehouse getting serialized, deleted, then deserialized, no detail lost)
Comparison against the second best serializer: Minstance
My results were tested in a roblox server, minstance’s results are taken from this post
This benchmark is based on a dumbed down version of the Crossroads Classic Map:
I know not all datatypes are included here, but they will be included in future versions, if you want to, suggest a format for a datatype!
I hope developers make great use of this and build the best instance serializer/deserializer
Any suggestions on improvements for this data format are accepted
Hey there
if you’re not providing the one you’ve made i suggest you change the post category to community tutorials instead of resources
nevertheless, this is pretty impressive
I’m not sure how much space this would save, but would it help to have a seperate small buffer for booleans so you can utilise 1 bit per boolean? Then that can be put at some place within the serialized file.
To deserialize, you would need another “boolean” cursor to move forward to read the boolean. If you have lots of boolean properties, it could save some bytes
Rbxms are XML based so they have a bunch of a junk that isn’t necessary, my format gets rid of any junk and also uses references for repeated names, enums, etc instead of repeating them over and over again (which would waste a lot of space, and rbxms do this). And as far as I know Roblox doesn’t offer an easy to use method that converts any instance to rbxm. So you would have to write a system for serializing rbxms from scratch, but then why write a system for rbxms (which can get complicated and waste lots of space) when you can make one that serializes/deserializes using my data format, which would take the same amount of effort or less
Deserialization time: (mine) 0.027s (minstance) unkown (i couldn’t find that data)
so yeah surprisingly my crappy instance serializer is better than minstance lol, if someone with some actual optimization skills wrote a serializer/deserializer for this the benchmarks would be insane. You can test this for yourself here
i have a question, why do you convert your vectors into int32s when vectors is already floats32s? that seems like needless data loss for something that’s already float32s??
[after this i realized a couple more flaws]
ids in the format seem very extraneous. you already know what the ids are, they would be in storing order. cutting out ids would be very good way to squeeze out more data. in a smaller footprint.
enums are also internally stored as strings in your format, but they dont even reach 24 bits in value, you can easily store a uint24 for all enums. we already know what enum is expected based off of our property as well. (reflectionservice)
font doesnt seem to be compressed very well; family as a string is fine, but you can store all other data in 4 bytes..
your number range uses float64s when theyre already stored in memory as float32s.
i personally wouldnt prioritize compression of cframes over accuracy, but in the case of this, i dont find 3 int 16s super data efficient. you could store as quaternion (write w, x, y, z, because w=0 means no rotation applied) int16s, and possibly yield higher compression in some cases due to zero rotation cframes. you can also store axis-aligned cframe rotations and save storing excessive rotation data
udims are f32s, but you did half them so im not really going to care (though storage type could be better. you can cut off half of a f32 to store a bfloat16)
colors are technically floats but everyone uses 3byte rgb anyways