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

Reduce unnecessary cloning of versions AND slow convergence to the optimal context #1217

Open
skrynski opened this issue May 17, 2022 · 0 comments · May be fixed by #1208
Open

Reduce unnecessary cloning of versions AND slow convergence to the optimal context #1217

skrynski opened this issue May 17, 2022 · 0 comments · May be fixed by #1208

Comments

@skrynski
Copy link
Collaborator

When running the snippet of code below using PIR_WARMUP=3 PIR_DEBUG=PrintPirAfterOpt,PrintToStdout, we see that f1 (f[0]) shows up several times in the compilation log, each time with a more specific context. The reason is that it takes several passes to the compiler to reach the optimal context. When the eager_call pass picks up a better context, it clones the current version and changes it. This is also not ideal since oftentimes we could reuse the same version and change it in place (if we can show that is not referenced somewhere else).
Both problems should be looked into. The PR linked here attempts to limit the cloning of versions by keeping a simple refCount mechanism. It doesn't seem to show much benefits, so maybe it is not worth merging. However, it does fix the issue in the example and manages to reduce the number of times the function gets cloned.

f <- function() {

    f1 <- function(x) {
        #print("inner")
         x + 4L
    }

    for (i in 1:10) {
        print(f1(i))
    }

    rir.functionInvocations(f1)
}

f()
f()
f()
f()
f()
f()
f()
@skrynski skrynski linked a pull request May 17, 2022 that will close this issue
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 a pull request may close this issue.

1 participant