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

Disable partial JIT invalidation on unmap #1991

Merged
merged 1 commit into from
Feb 7, 2021

Conversation

gdkchan
Copy link
Member

@gdkchan gdkchan commented Feb 2, 2021

One of the changes on #1518 caused a large performance regression (mainly during load) on games that unmap memory frequently. This happens because it checks if the JIT cache has a function overlapping the unmapped range on each unmap, which right now is very slow as the data structure used is not really suitable for quick match of overlapping ranges.

This changes fixes the performance regression by completely removing the invalidation on unmap. The reason for this is because it was already largely incomplete anyway, as it does not actually remove the host code from the cache (possibly causing it to use all the memory reserved for the JIT cache, if the game is generating or loading code at runtime), and because the functions being removed from the cache does not become complete unreachable by just removing it from the dictionary, since that, due to the direct call optimization, they can be still reachable from calls that load the function address from the jump/dynamic call tables.

Meanwhile this keeps the bits that actually fixes the issue I noticed and motived me to make the original changes anyway, which was rejiting trying to translate a function that was already unmapped. It does this by just clearing the rejit queue on each unmap. This also fixes a bug on that part where a function could be stuck in LowCq forever, if it was added to the rejit queue, and a overlap was found on unmap, causing the rejit queue to be cleared. Now it resets the call count of all functions removed from the rejit queue, giving them another chance to be rejited.

The affected games are mainly those that makes heavy use on Map/UnmapPhysicalMemory, like a few UE4 games. The boot times seems now close to what it was before the aforementioned PR.

@gdkchan gdkchan added cpu Related to ARMeilleure enhancement New feature or request labels Feb 2, 2021
Copy link
Member

@riperiperi riperiperi left a comment

Choose a reason for hiding this comment

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

Looks fine for now.

Copy link
Contributor

@marysaka marysaka left a comment

Choose a reason for hiding this comment

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

lgtm

@jduncanator jduncanator merged commit ee28cce into Ryujinx:master Feb 7, 2021
@gdkchan gdkchan deleted the no-jit-invalidation branch April 2, 2021 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpu Related to ARMeilleure enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants