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

avm2: share binding skip optimization with call_method #16197

Merged
merged 1 commit into from
May 6, 2024

Conversation

J0sh0nat0r
Copy link
Contributor

This PR shares the optimization from call_property which skips binding methods that don't need receivers with call_method. Currently, for example, Chess Demons allocates almost 1GB of unnecessary function objects during loading, this patch fixes that:

Command                            USS 
./ruffle_desktop_opt cd.swf       1.5G 
./ruffle_desktop_no_opt cd.swf    2.5G

A quick perf stat run shows a small decrease in loading time and page faults cut in half:

Performance counter stats for './ruffle_desktop_opt cd.swf':

        20,082.41 msec task-clock:u                     #    0.582 CPUs utilized             
                0      context-switches:u               #    0.000 /sec                      
                0      cpu-migrations:u                 #    0.000 /sec                      
          376,719      page-faults:u                    #   18.759 K/sec                     
   94,845,384,958      cycles:u                         #    4.723 GHz                       
  182,895,351,746      instructions:u                   #    1.93  insn per cycle            
   29,683,116,696      branches:u                       #    1.478 G/sec                     
      199,608,906      branch-misses:u                  #    0.67% of all branches           

     34.511689417 seconds time elapsed

     18.827233000 seconds user
      1.218733000 seconds sys
Performance counter stats for './ruffle_desktop_no_opt cd.swf':

        21,512.53 msec task-clock:u                     #    0.592 CPUs utilized             
                0      context-switches:u               #    0.000 /sec                      
                0      cpu-migrations:u                 #    0.000 /sec                      
          634,737      page-faults:u                    #   29.505 K/sec                     
  100,060,811,478      cycles:u                         #    4.651 GHz                       
  187,065,447,138      instructions:u                   #    1.87  insn per cycle            
   30,586,698,113      branches:u                       #    1.422 G/sec                     
      189,874,657      branch-misses:u                  #    0.62% of all branches           

     36.345462896 seconds time elapsed

     19.933122000 seconds user
      1.542323000 seconds sys

Thanks to @adrian17 for figuring out the problem and suggesting this fix!

core/src/avm2/object.rs Outdated Show resolved Hide resolved
@J0sh0nat0r J0sh0nat0r force-pushed the share-call-property-opt branch 2 times, most recently from 0fd97ea to cfe1172 Compare May 5, 2024 00:52
@adrian17 adrian17 enabled auto-merge (rebase) May 6, 2024 19:52
@adrian17 adrian17 merged commit 0c38cc9 into ruffle-rs:master May 6, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants