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

Automatically use compiled mode when possible #203

Closed
staticfloat opened this issue Mar 20, 2019 · 3 comments
Closed

Automatically use compiled mode when possible #203

staticfloat opened this issue Mar 20, 2019 · 3 comments

Comments

@staticfloat
Copy link

It would be very neat if the interpreter could figure out when compiled mode won't degrade the debugging experience. Unless I am mistaken, we can figure out all methods that must be interpreted by following backedges from all locations where a breakpoint could occur (e.g. our list of breakpoints and all throw() instances, if break_on(:error) is set) and marking all those methods as "must interpret". Any other method, if not stepped into should automatically be switched to compiled mode.

This kind of backedge calculation should be exactly the same as what is used by #265 to trigger recompilation. There may be additional complexity around code within the compiler that can call jl_throw() from C code (e.g. allocation failure) which we will miss within the interpreter like this, but I don't know if that is caught within the interpreter as of today anyway.

@KristofferC
Copy link
Member

AFAIU, backedges are there to make sure optimizations are still valid on method redefinitions, so type inference and inlining. But in purely dynamic cases, where we do no optimizations there are no backedges. But even in those cases we want to intercept breakpoints. For example:

function has_a_bp()
    @bp
    return 5
end

const S = Any[has_a_bp]

function maybe_bp()
    rand() < 0.001 && S[1]()
end

I don't see how we could ever figure out that maybe_bp could have a breakpoint.

@staticfloat
Copy link
Author

Ah, of course, you're right. My idea only works for static subchunks where you can infer the callgraph completely. I've spent too much time working in TPU-land where that's a given. :P

@timholy
Copy link
Member

timholy commented Mar 21, 2019

I think the right solution is just to solve our performance problems. Would be lovely to get your input on #204, @staticfloat.

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