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

Implement fast path for AES crypto instructions on Arm64 #5281

Merged
merged 3 commits into from Jun 11, 2023

Conversation

gdkchan
Copy link
Member

@gdkchan gdkchan commented Jun 10, 2023

As the title says. This greatly improves the performance of AES operations when using JIT on Arm64 platforms. It is most notable on Animal Crossing when the game is saving, since it apparently encrypts the save data, and before this change that would cause noticeable stutters.

Closes #5263.

@gdkchan gdkchan added cpu Related to ARMeilleure performance Performance issue or improvement labels Jun 10, 2023
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.

Nice. 😌

@gdkchan
Copy link
Member Author

gdkchan commented Jun 10, 2023

I tested Animal Crossing on macOS and it's working properly (no more heavy stutter when saving with JIT). I also ran the Crypto test (and Crypto32 too) on a Raspberry Pi 4, they all pass, but unfortunately the Raspberry Pi CPU does not support the AES extension, so it was still taking the slow paths there. It would be nice if someone could run the tests on Arm64 Linux with a CPU that supports AES. Almost none of the CPU tests run on Arm64 macOS right now AFAIK due to Unicorn issues.

@aletrevi99
Copy link

this pr also cuts loading times by more than half in acnh! used to take around 10 seconds to load a new room for example, now around 3/4 seconds

@jduncanator
Copy link
Contributor

Tests are passing correctly on an ARM64 Linux target here:

Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
Test run for src/Ryujinx.Tests/bin/Debug/net7.0/Ryujinx.Tests.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.6.0 (arm64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
NUnit Adapter 4.1.0.0: Test execution started
Running selected tests in src/Ryujinx.Tests/bin/Debug/net7.0/Ryujinx.Tests.dll
   NUnit3TestExecutor discovered 24 of 24 NUnit test cases using Current Discovery mode, Non-Explicit run
  Passed Aesd_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,4173465908070920181UL,9943920176957912833UL,10217182921803957948UL,10328748588515655053UL) [395 ms]
  Passed Aesd_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,4173465908070920181UL,15351740853312108513UL,10217182921803957948UL,10328748588515655053UL) [4 ms]
  Passed Aesd_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,8827430708575053269UL,9943920176957912833UL,10217182921803957948UL,10328748588515655053UL) [2 ms]
  Passed Aesd_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,8827430708575053269UL,15351740853312108513UL,10217182921803957948UL,10328748588515655053UL) [2 ms]
  Passed Aese_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,14273691190541683539UL,4127970860932264262UL,10345507550822998093UL,5492616109554313292UL) [3 ms]
  Passed Aese_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,14273691190541683539UL,1690253263847695179UL,10345507550822998093UL,5492616109554313292UL) [2 ms]
  Passed Aese_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,10484708430689203144UL,4127970860932264262UL,10345507550822998093UL,5492616109554313292UL) [2 ms]
  Passed Aese_V(uint.MinValue,1,8888791084251240037UL,7166475444035995485UL,10484708430689203144UL,1690253263847695179UL,10345507550822998093UL,5492616109554313292UL) [2 ms]
  Passed Aesimc_V(uint.MinValue,1,10217183059242911420UL,10328748588515655053UL,15435426261652692654UL,17206508408432187255UL) [3 ms]
  Passed Aesimc_V(uint.MinValue,uint.MinValue,10217183059242911420UL,10328748588515655053UL,15435426261652692654UL,17206508408432187255UL) [2 ms]
  Passed Aesmc_V(uint.MinValue,1,7096106647905438152UL,3105288063291732965UL,8888791084251240037UL,7166475444035995485UL) [3 ms]
  Passed Aesmc_V(uint.MinValue,uint.MinValue,7096106647905438152UL,3105288063291732965UL,8888791084251240037UL,7166475444035995485UL) [2 ms]
  Passed Aesd_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,2290942773153415507UL,11919168958138124598UL,10217182921803957948UL,10328748588515655053UL) [16 ms]
  Passed Aesd_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,2290942773153415507UL,9519032407040401072UL,10217182921803957948UL,10328748588515655053UL) [8 ms]
  Passed Aesd_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,4689522466461389379UL,11919168958138124598UL,10217182921803957948UL,10328748588515655053UL) [4 ms]
  Passed Aesd_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,4689522466461389379UL,9519032407040401072UL,10217182921803957948UL,10328748588515655053UL) [4 ms]
  Passed Aese_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,16289406851345172903UL,13102951385261698891UL,10345507550822998093UL,5492616109554313292UL) [5 ms]
  Passed Aese_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,16289406851345172903UL,14608110044635135832UL,10345507550822998093UL,5492616109554313292UL) [4 ms]
NUnit Adapter 4.1.0.0: Test execution complete
  Passed Aese_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,16515115464934646839UL,13102951385261698891UL,10345507550822998093UL,5492616109554313292UL) [4 ms]
  Passed Aese_V(uint.MinValue,2,8888791084251240037UL,7166475444035995485UL,16515115464934646839UL,14608110044635135832UL,10345507550822998093UL,5492616109554313292UL) [4 ms]
  Passed Aesimc_V(uint.MinValue,2,10217183059242911420UL,10328748588515655053UL,15435426261652692654UL,17206508408432187255UL) [5 ms]
  Passed Aesimc_V(uint.MinValue,uint.MinValue,10217183059242911420UL,10328748588515655053UL,15435426261652692654UL,17206508408432187255UL) [5 ms]
  Passed Aesmc_V(uint.MinValue,2,7096106647905438152UL,3105288063291732965UL,8888791084251240037UL,7166475444035995485UL) [6 ms]
  Passed Aesmc_V(uint.MinValue,uint.MinValue,7096106647905438152UL,3105288063291732965UL,8888791084251240037UL,7166475444035995485UL) [4 ms]

Test Run Successful.
Total tests: 24
     Passed: 24
 Total time: 20.9817 Seconds

@AcK77 AcK77 merged commit 193ca3c into Ryujinx:master Jun 11, 2023
8 checks passed
@gdkchan gdkchan deleted the a64-aes branch June 11, 2023 00:57
@fnsmake
Copy link

fnsmake commented Jun 11, 2023

run smooth! thank u for your work~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpu Related to ARMeilleure performance Performance issue or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]Animal Crossing autosave lag
7 participants