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

Conversation

@Ghabry
Copy link
Member

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 some commits Apr 30, 2019

Improve Cache management: Besides timeout unused bitmaps and SEs are …
…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

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link
Member Author

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

Ghabry added some commits May 6, 2019

Support caching of Sprite effects.
Reduces the memory usage significantly when a screen flash or tone is applied because this created new bitmaps for each event before.

Fix #1755
Effects now only allocate a bitmap with the size of the sprite rect (…
…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 Ghabry force-pushed the Ghabry:cache_tone branch from 7982f4d to 33d3946 May 7, 2019

@fmatthew5876

This comment has been minimized.

Copy link
Contributor

commented on src/audio_secache.cpp in e1cef31 May 8, 2019

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

@Ghabry

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link
Contributor

commented May 12, 2019

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.

@fmatthew5876
Copy link
Contributor

left a comment

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

@carstene1ns carstene1ns merged commit 112f346 into EasyRPG:master May 26, 2019

7 checks passed

Android (armeabi-v7a) Build finished.
Details
GNU/Linux Build finished.
Details
OSX Build finished.
Details
Wii (SDL1) Build finished.
Details
Windows (x64) Build finished.
Details
Windows (x86) Build finished.
Details
web Build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.