Skip to content

avm1: Cache ConstantPools for constant pools with more than 1000 entries #11980

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lord-McSweeney
Copy link
Collaborator

This makes Tiny Battle (see #9785 (comment)) play at a reasonable speed after #11957. The game was using a constant pool with >18000 entries, which got re-interned in Ruffle every time the DoAction tag was iterated over.

@Lord-McSweeney Lord-McSweeney force-pushed the avm1-constant-pool-cache branch from 9d05e2f to c66cfd4 Compare July 10, 2023 02:08
@@ -27,6 +28,8 @@ pub struct Avm1<'gc> {
/// don't close over the constant pool they were defined with.
constant_pool: Gc<'gc, Vec<Value<'gc>>>,

constant_pool_cache: HashMap<SwfPosition, Gc<'gc, Vec<Value<'gc>>>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

If SWFs are repeatedly loaded then unloaded, this will cause a memory leak; this should probably be a weak_table::WeakKeyHashMap instead.

@moulins
Copy link
Contributor

moulins commented Jul 11, 2023

Why limit the caching to >1000 entries constant pools? I don't think always caching has any extra performance cost.

@Dinnerbone Dinnerbone added the waiting-on-author Waiting on the PR author to make the requested changes label Jul 17, 2023
@danielhjacobs danielhjacobs added A-avm1 Area: AVM1 (ActionScript 1 & 2) T-perf T-perf Type: Performance Improvements and removed T-perf labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2) T-perf Type: Performance Improvements waiting-on-author Waiting on the PR author to make the requested changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants