-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redo serialize.lua #11427
Redo serialize.lua #11427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall needs more comments to describe what each step does for easier maintenance and better understanding.
Erroneous code style
See comments
This still closes #8719 |
This should be unit tested to cover compatibility and edge cases See how vectors have unit tests in https://github.com/minetest/minetest/blob/master/builtin/common/tests/vector_spec.lua |
Minetest already has unit tests for serialization and this passes them, plus my modlib unit tests (as already said). I should definitely add FaceDeer's example to the unit tests though. |
oh right, I wrote them. It would be good to add tests for previous shortcomings, such as "Support for arbitrary references, including self-referencing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should work. Didn't test though.
Some more comments and empty lines wouldn't hurt.
(If you want to further improve the performance, I'd suggest using luajit's profiler.)
Bump. 5.5 could use this. |
It looks like I'm duplicating part of the |
From a brief non-thorough test with one of my mods that serializes a fair amount of data, this seems to work as expected. Notably, the resulting data was significantly smaller with this patch due to the way keys are handled. The code itself also seems fine, I had to slow down reading it but it's still understandable. I'd call this good to merge with a couple caveats
I think the best time would be directly after 5.5 is released though, the potential harm that a missed bug could do here is very high and this will give time for us to see more real-world behavior during the 5.6 release cycle. |
Agreed. Get 5.5 out first, it's already late. I'll see where I can find good real-world test cases. It'd be nice if there were some voluntary "testers". I believe @erlehmann could be one of them ;). |
The latest commit massively improves the coverage, testing thousands of primitives and tables through fuzzing. I had to write my own |
This reverts commit 438a635.
Can we cut down on trailing commas? Also these should probably be declared as locals: Also² this breaks WorldEdit's deserialize workaround on LuaJIT. It was bound to happen of course but it's not fun to figure out a fix. (Don't worry about this) |
We can and we did. Desour seems to prefer trailing commas though.
Locals are capped at 255. I don't want to increase the code complexity (or impose arbitrary limits) for a negligible performance benefit.
|
Trailing commas definitely do hurt.
Wasn't even thinking of (theoretical) performance benefits, but sure, keep it like this. |
Co-authored-by: sfan5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested mainly with WorldEdit schematic serialization
Alternative to #11380. Not yet thoroughly tested, but passes the (few) unit tests provided, as well as my own tests. Closes #8719.
Features:
Benchmarks
LuaJIT. Write speeds, Luon is the name of the modlib module, Bluon is a binary format, Minetest is the old
minetest.serialize
, Minetest (JSON) isminetest.write_json
. The times shown are what 100 serializations take. Data fromhttps://github.com/miloyip/nativejson-benchmark/tree/master/data.
("reopened" #11425)