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 modulegraph stack depth and implement 'yield from' #5698
Conversation
Can you talk me through commit number 2 f7032a9? It looks like you've just moved things which is fine - it's just a headache to review because git doesn't recognise it as a couple of moves.
For the record, we are looking to ditch modulegraph in favor of modulegraph2 which uses a todo list/queue instead of recursion (and thus avoids the recursions errors) so this will probably all be made redundant. |
The code in
I saw that, but I haven't seen the latest on that. For the record, I attempted to do this, but faced several problems, once of which was that the todo queue (which I assume will be a (Note: see 23c2b1a). |
I'm surprised by that. Both that it's slower and that it's significant. I did some But anyway... Can you:
Then it's the green flag from me. PS: @rokm the counting stars test has died again. |
@bwoodsend Is there existing work on integrating modulegraph2? |
@Legorooj Go anything worth salvaging? |
There's some existing work I was doing, however I had to take a break for multiple reasons. I got one major takeaway though: modulegraph2 is not stable. Too many bugs to directly integrate it into PyInstaller. To be honest, I think we'd have more success with rewritiing modulegraph ourselves. I did a decent bit of research into doing this, and it wouldn't be too hard. We'd end up with a custom codebase that we'd have to maintain, true, but we'd also understand it a lot better. I may attempt this sometime soon, not sure though. |
That's not correct. Modulegraph is an incredibly difficult problem due to the way it's set-up. The import ordering must be correct, and there are many quirks that have been patched in the current PyInstaller version of modulegraph. If you really want to tackle this, I suggest you copy the modulegraph 2 files into the lib folder, and then add configuration options to allow selection of the modulegraph library (use git rewrite history to keep the commit history). Then, modulegraph 2 bugs can be fixed over time. |
This should absolutely be merged though, as modulegraph 2 is not happening anytime soon. |
I plan to merge this once CI passes.
Yes. However, Python's import specifications actually make a lot of sense. IMO a lot of code in modulegraph isn't handled well.
Having all these quirks fixed in PyInstaller is why it'll be easy enough.
This wouldn't work. Modulegraph2 is incredibly different. The code to support both mg1 and mg2 would be massive. Plus, vanilla modulegraph2 wouldn't work for us; it doesn't have certain features which we need. We wouldn't be able to integrate the current PyInstaller hook methodology into mg2, for example. mg2 is still, in my opinion, a prototype. It's not production ready in the slightest. I'm talking to the extent the |
@Legorooj is there anything else on this? |
In testing, these changes were found to reduce the maximum stack depth by 23%. The analysis procedure is patching analysis.py as such (https://gist.github.com/xoviat/0b66194bdd2b07f9720f44f170536420) and running the tests.