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

Better optimization of side exits by recording type information #680

Open
markshannon opened this issue May 20, 2024 · 2 comments
Open

Better optimization of side exits by recording type information #680

markshannon opened this issue May 20, 2024 · 2 comments
Assignees

Comments

@markshannon
Copy link
Member

When optimizing a side exit, it would be useful to know what types and values are guaranteed. Many side traces start with guards that are unnecessary as the type of values is guaranteed by the previous executor.
However, we do not currently use that information when optimizing side guards.
If we were to record that information on exits, then we could do a better job optimizing exits.

For example, given the following code snippet:

x = a + b # ints
if (cond): # Not taken
    return x + a + b

If there is a side exit at the branch if(cond), then we should know that x, a and b are ints, but we throw that information away, resulting in extra guards in the final trace for return x + a + b

One record per executor

Instead of retaining type information on side exits, we can keep the type information at the entry to the trace and recompute the type information before optimizing the new side trace.
(Credit @Fidget-Spinner)

Although this would slow down the optimizer a bit, it would save quite a lot of memory.

@brandtbucher
Copy link
Member

We need to be careful not to insert side-exit executors into the tier one bytecode when doing this, right? I forget if we insert them currently...

@Fidget-Spinner
Copy link
Collaborator

We need to be careful not to insert side-exit executors into the tier one bytecode when doing this, right? I forget if we insert them currently...

IIRC this would be done at the end of the optimization pass. So it shouldn't affect anything. Assigning this to myself.

@Fidget-Spinner Fidget-Spinner self-assigned this Sep 11, 2024
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

No branches or pull requests

3 participants