Skip to content
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

Proposal: Have a tool that converts all the XML files to binaries for the client #34

Open
raduprv opened this issue Oct 6, 2016 · 2 comments

Comments

@raduprv
Copy link
Owner

raduprv commented Oct 6, 2016

I don't think it makes much sense loading XML at runtime, especially since it very rarely changes.
I think it would be better if there was a tool that converted all the XML files to binaries, that are loaded at runtime by the client. This way we get rid of two dependencies (libxml2 and iconv), and would speed things up a bit, especially for slower devices, such as phones, raspberry pies, etc.

@gvissers
Copy link
Collaborator

LOL. I had some fun making a start on this. Check my dexml branch (https://github.com/gvissers/Eternal-Lands/tree/dexml) if you want to play.

Anyway, I thought I'd try to start by converting the XML to C code, which is then compiled into the executable directly. It saves the hassle of having to write import functions, and since we're dealing with text files it is much easier to debug. Optimistically I started with the actor definitions. Well, nearly two weeks and 200,000 lines of generated code later, I'm happy to say that the process worked. Of course the default (debug) build ballooned from 3.2M to 21M, and the overall speedup of the boot process is questionable, but it works.

So here's some numbers, five runs, all wall clock time. The time spent in init_actor_defs is indeed nearly halved.The variances in the overall boot time are much greater than any potential savings though. (well, I did only test it on my latop, which is reasonably fast and has an SSD. YMMV).

Actor defs parsed at runtime, default build:
Size of executable: 3.2M
init_actor_defs: 0.358 0.356 0.358 0.355 0.351
init_stuff: 1.687 1.211 1.613 1.656 1.255
avg init_actor_defs: 0.36s

Actor defs compiled in, default build
Size of executable: 21M
init_actor_defs: 0.165 0.166 0.181 0.207 0.177
init_stuff: 1.422 1.679 0.953 1.023 1.435
avg init_actor_defs: 0.18s

Actor defs parsed at runtime, release build:
Size of executable: 2.9M
init_actor_defs: 0.324 0.374 0.336 0.320 0.322
init_stuff: 1.414 1.026 1.005 1.161 1.115
avg init_actor_defs: 0.34s

Actor defs compiled in, release build
Size of executable: 7.9M
init_actor_defs: 0.151 0.140 0.160 0.153 0.144
init_stuff: 1.172 0.720 0.825 0.758 0.742
avg init_actor_defs: 0.15s

Anyway, now that I've hashed out how to store the data, I can more easily come up with a binary file format. For the encyclopedia we probably want to do this anyway, since I've just realized that that's 14M of XML data (as opposed to just 600K for the actor defs, though the latter includes a lot of its files multiple times for different actor types).

@raduprv
Copy link
Owner Author

raduprv commented Mar 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants