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

Cache improvements and effect caching #1760

Merged
merged 6 commits into from May 26, 2019
Merged

Conversation

Ghabry
Copy link
Member

@Ghabry Ghabry commented May 6, 2019

not ready yet, have strange flickering.

Improved the caching strategy, before our Cache was unlimited and never cleared any recently (<5s) used assets. Now the clear is forced when the memory usage is 10 MB (+3 MB SE).

Which means the memory foodprint is in simple games (havn't used the MSVC memory profiler yet) ~20 MB plus Database.

Besides reduced memory usage the effect cache should also help in some situations to make the effect faster because tone & flash are only calculated once now per same charset.

Related #1177

Ghabry added 2 commits May 6, 2019 23:55
…now deleted when the memory threshold is exceeded.

Dummy assets are now cached: Improves Game Browser startup time
@Ghabry Ghabry added the Bitmaps label May 6, 2019
@fdelapena fdelapena added this to the 0.6.1 milestone May 6, 2019
@Ghabry
Copy link
Member Author

Ghabry commented May 6, 2019

Comparison images: (already making them now, as the "flicker fix" won't increase the memory usage)
The biggest impact has "Fix the out of bounds check code" but combined with "Support caching" it helps to prevent increase of memory usage over time (when more parts of the map are visited).

Note: These are manual recordings, so the time axis won't match, look at the memory usage.

Obviously highly suggestive because I picked the most crazy examples. In IB e.g. the change is around 0, stays at ~22 MB the whole time.

The Looking Glass:

Master:
glass_before-fs8

This branch up to "Fix out of bounds":
glass_before2-fs8

This branch all commits:
glass_after-fs8

RPG_RT: 21 MB but they have two advantages: They use 16bit and for Tone effect they modify the palette instead of copying.

Yume2kki

Master: (32bit limit -> crash)
yume2kki_before-fs8

This branch up to "Fix out of bounds":

yume2kki_before2-fs8

This branch all commits:
yume2kki_after-fs8

RPG_RT: 37 MB

@Ghabry
Copy link
Member Author

Ghabry commented May 7, 2019

The flicker fix also will contain yet another minor improvement: It saves 258 KB per CharSet that is affected by a screen effect. Saves a non measurable amount for "The Looking Glass" and 2 MB in Yume2kki.

The "Operator <" is required for keys in std::map.

@Ghabry Ghabry changed the title WIP: Cache improvements and effect caching Cache improvements and effect caching May 7, 2019
@Ghabry Ghabry marked this pull request as ready for review May 7, 2019 20:54
Ghabry added 4 commits May 7, 2019 23:06
Reduces the memory usage significantly when a screen flash or tone is applied because this created new bitmaps for each event before.

Fix EasyRPG#1755
…src_rect_effect).

Sprite rects are only used by Charsets, this change saves 250 KB per individual charset when a screen effect is used.
For all other cases sprite rect == bitmap rect.
@Ghabry
Copy link
Member Author

Ghabry commented May 10, 2019

Does this require constexpr? It could be useful as a tunable parameter in RPG_RT.ini

I can make it non-const.
Though I don't see that much use in making this tunable. You will always need at least a small cache for reducing lag on slow systems (e.g. without the SE cache Yume Nikki was unplayable on older systems because the IO and the decode took too long).
And even on newer systems not caching e.g. the system graphic has a noticable performance penalty, the Game Browser startup speed is now instant instead of delayed (and I always thought the cause is the FileFinder...)

@fmatthew5876
Copy link
Contributor

Does this require constexpr? It could be useful as a tunable parameter in RPG_RT.ini

I can make it non-const.

Unless it's going to be exposed as a runtime config parameter I would leave it constexpr, at least then you can maybe eke out some additional compile time optimizations.

Copy link
Contributor

@fmatthew5876 fmatthew5876 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this LGTM, though I admit I am not that familiar with this corner of the code.

@fdelapena fdelapena added the Performance Related to improvements on memory, less CPU or disk usage, battery savings, etc. label May 26, 2019
@carstene1ns carstene1ns merged commit 112f346 into EasyRPG:master May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bitmaps Performance Related to improvements on memory, less CPU or disk usage, battery savings, etc.
Development

Successfully merging this pull request may close these issues.

None yet

4 participants