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

feature: hash source with AST #1074

Open
majidaldo opened this issue Jun 24, 2020 · 6 comments
Open

feature: hash source with AST #1074

majidaldo opened this issue Jun 24, 2020 · 6 comments

Comments

@majidaldo
Copy link

It's a bit annoying that the cache gets invalidated by trivial non-functional code changes. Has anyone thought of hashing the ast to identify a function?

@ogrisel
Copy link
Contributor

ogrisel commented Jul 2, 2020

That's an interesting suggestion. I wonder if it could have a performance impact though.

@pierreglaser wants to investigate with a bad interaction that prevent caching to work as expected when:

  • the function is dynamically defined in __main__
  • the function is cached with memory
  • the function is called by Parallel with the loky backend

all 3 at the same time.

Using the AST instead of the source might be a fix for the above problem.

@majidaldo
Copy link
Author

majidaldo commented Jul 2, 2020

  • the function is cached with memory

you mean the Memory object?

@pierreglaser
Copy link
Contributor

I agree that it's a good suggestion. That could also simplify the codebase.
@ogrisel if you think that could be an option, I can investigate this.

@ogrisel
Copy link
Contributor

ogrisel commented Jul 15, 2020

@pierreglaser feel free to investigate, in particular in the context of the bug you described to me IRL and that I tried to summarize in #1074 (comment). Please open a dedicated issue for the bug itself if you can come up with a simple reproducer.

@majidaldo
Copy link
Author

majidaldo commented Sep 7, 2020

I went ahead and gave it a shot. I only did a quick test and it seems to work.

It's crude though and just demonstrates the concept. The ast hashing was straightforward but I couldn't follow all the (existing) code. Function source refs seems to be entangled with its hashing.

@majidaldo
Copy link
Author

bump @pierreglaser

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