And versioning? I could create cache, then install new version of OXCE and then what? it will load incompatible byte data?
You're right. OXCE exe file info would also need to be included in the hash. So if any Rule object changes, the exe file changes, hash changes, and it invalidates the cache.
Beside I still hold my stance that if you do not refactor whole loading process you will not archive your goal.
For start I can say you do not success as one thing you would need serialize script code that can have embedded pointers.
Have fun reinterpreting byte array for search of them.
Hmm, that does sound like a problem. I guess the solution for that would be to postpone script compiling until after the Rule objects are loaded. So what would be serialized instead would the script text.
You know, after checking the code, the pointers might be less of a problem than I thought, because all the linking (pointer setting) is already happening in the
afterLoad() functions of the objects. But yeah, a little bit of refactoring would be necessary to move script compilation from
load() to
afterLoad(). I might need your help with that!
For instance, in the
RuleStatBonus::load(), first the script text is generated, and then
_container.load(parentName, script, parser); is called to compile the script. How would I change this function so that script text is saved, so that I'm able to compile the script code later?
Btw, I think it's a bug that script compilation is already happening in
load() instead of
afterLoad()... the load() function was supposed to only extract data from YAML.
What exactly take most of time during load?
Inside the
loadMods(), 70% of the CPU time is consumed by
YAML::load() - just YAML parsing, and 30% by Rule generation. At least in large mods. So a much easier solution would be to de/serialize the parsed YAML::Node objects instead of the Rule objects. But then the end result would be
only a 70% reduction of loading time...
I have personal experience of helping implementing and using a serializer/deserializer commercially at work
So do I, but that was a different language, different format, and much smaller in scale.
If the change is not too invasive, it can be considered.
If we'd need to "rewrite" all the Rule* classes, then it's a no go.
That doesn't sound very reassuring.
I think this would be a far better and saner approach.
But but... only 70%!