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

liblcf is reading the whole RPG_RT.ldb twice on init #169

Open
fdelapena opened this issue Feb 23, 2016 · 5 comments
Open

liblcf is reading the whole RPG_RT.ldb twice on init #169

fdelapena opened this issue Feb 23, 2016 · 5 comments

Comments

@fdelapena
Copy link
Contributor

fdelapena commented Feb 23, 2016

Some games have large database files and it can be slow parsing it completely.

Furthermore, the file is parsed twice: first to get some strings to detect the encoding with ICU, and then parsed again with the detected encoding.

For a proof of concept, try the Hero's Realm HTML5 version:
https://easy-rpg.org/play/master/?game=heros_realm

It should allow to do selective parsing of data instead of eager loading.

@Ghabry
Copy link
Member

Ghabry commented Feb 23, 2016

Could be combined with a reader_struct refactor ;)

@mateofio
Copy link
Contributor

mateofio commented Oct 5, 2018

Lazy reading incurs a branch on every read because you always have to check if it's loaded or not. Most things in the database are used frequently enough you'd want them in main memory all the time.

One way we could speed up load times is by tricking the user. When starting up Player, we could load only the bare minimum required the operate the title screen and load menu. Then, while the user is on the title screen, we continue loading the rest of the database (and maybe the maps of his saves in order of most recent save) in a background thread. By the time the user picks new game or loads, a lot of, if not all of the lcf reading is done.

@fdelapena
Copy link
Contributor Author

Since 0.6.2, games load even faster than RPG_RT. Maybe this issue can be closed.

@mateofio
Copy link
Contributor

mateofio commented May 11, 2020

Reading everything twice is still pretty bad and fixing this could speed up significantly more. For large games like Heroes Realm and HH3, the in memory LDB is the biggest memory hog of the entire engine.

Maybe it's possible to do something which only loads enough partial string data to figure out encoding and exits.

I'd like to leave this open until address the double load issue.

@fdelapena fdelapena changed the title Do lazy reading instead of reading the whole file twice on init liblcf is reading the whole RPG_RT.ldb twice on init May 11, 2020
@Ghabry
Copy link
Member

Ghabry commented Sep 24, 2020

this will be solved when Saves use DBString, before we can't get rid of the Encode functions in the parsing code.

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

No branches or pull requests

3 participants