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

Needs optimization #1

Open
shashikdm opened this issue Jun 3, 2019 · 1 comment
Open

Needs optimization #1

shashikdm opened this issue Jun 3, 2019 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@shashikdm
Copy link
Owner

The current implementation takes the entire trace of the cassette pass and operates on it. which makes it heavy in terms of space and time. possible improvement options:

  1. generate the graph in-place during the cassette pass instead of a trace
  2. do not trace function calls for functions in ignorelist.

@oxinabox can you help me with option 2?
Specifically how to tell Cassette to not overdub certain functions that may occur inside the called function?

@shashikdm shashikdm added the help wanted Extra attention is needed label Jun 3, 2019
@oxinabox
Copy link

oxinabox commented Jun 3, 2019

Yep,
so say you want to ignore all functions called within foo
but not foo itself.

I believe you should be able to do:

Cassette.overdub(ctx::TraceCtx, ::typeof(foo), args...) = foo(args...)

since that will get rid of the default behavour of recursively overloading.

So to do a list of such functions.

for func in ignorelist
    @eval Cassette.overdub(ctx::TraceCtx, ::typeof($func), args...) = $func(args...)
end

BTW:
It might be easier to work with just overdub rather than prehook and posthook

function Cassette.overdub(ctx::TraceCtx, f, args...)
    enter!(ctx.metadata, f, args...)
    try
        if Cassette.canrecurse(f, args...)
            return Cassette.recurse(f, args...)
       else
           return Cassette.fallback(f, args...)
       end
    finally
        exit!(ctx.metadata, f, args...)
    end
end

@shashikdm shashikdm added enhancement New feature or request and removed enhancement New feature or request labels Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants