-
Notifications
You must be signed in to change notification settings - Fork 1.3k
RustPython initialization is slow #1047
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
Comments
Well, sadly It's not as straightforward as doing a simple git-bisect to find what's causing this, because many commits are broken and either not compiling / panicking, and the "good" execution time for my little benchmark is inconsistent. Anyways, I suspect that maybe some of the "importlib" changes are causing this because this is around the time that execution time skyrockets from ~0.120 to 0.7-2 for me EDIT: Okay, it is indeed caused by this pull request: #1018. before e88d6ac: $ git checkout 7ff59b27d77941465226c4157614f5b210bf25de
$ time target/debug/rustpython tests/snippets/strings.py
target/debug/rustpython tests/snippets/strings.py 0.26s user 0.01s system 99% cpu 0.271 total Now notice the increase $ git checkout e88d6ac1ef5f7e683f9a993b5a613bd16e868afe
$ time target/debug/rustpython tests/snippets/strings.py
target/debug/rustpython tests/snippets/strings.py 0.56s user 0.00s system 99% cpu 0.562 total If we test the last commit of the PR, that we get the abnormal execution time again: $ git checkout 1de9f73bd076b559189841de72446a96e1c7ffd2
$ time target/debug/rustpython tests/snippets/strings.py
target/debug/rustpython tests/snippets/strings.py 2.85s user 0.04s system 99% cpu 2.918 total |
That's odd though, because import machinery itself only takes ~15% of the execution time, you can test by changing the top of the file to: import time
t1 = time.time()
from testutils import assert_raises
print(time.time() - t1)
Maybe there was some other change in #1018 that caused this performance regression? |
Although, maybe it's importlib intialization, just running Edit: No, that only takes ~300ms, and happens almost immediately; the majority of the delay occurs after. |
Yeah, this is so weird! Look at this:
Most of the delay happens before the file is even loaded or parsed! Here's an asciinema to better illustrate the time at which they're logged. |
Ah, it is Edit: the two largest delays from the function come from |
I have not tried the rust profiling tools, but this might be a good moment to try them out! |
CPython also have some of the functions implemented in C for optimization. The better solution is probably trying to make RustPython faster 😏 |
Did anyone take a look at the logging? Each function invocation is logged using the rust logger. This might be overkill. Also, creation of exceptions is logged. Could this be causing the slow down? |
Uh oh!
There was an error while loading. Please reload this page.
A recent change probably made the interpreter extremely slow, this can be demonstrated by a simple benchmark:
I'm currently doing a
git-bisect
to identify which change introduced the poor performance, and I'll update what I find.The text was updated successfully, but these errors were encountered: