-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improve octoprint gcode analysis speed #2730
Conversation
I'm blind or replacing if None with if float("inf") cuts 30% of the execution time? I'd report that as python bug :( |
Three changes.
Check for yourself. I measured 30% on my laptop. |
I faked unit tests. The comparison should be: is min greater than max then return None. |
Looks like you broke one of the existing tests there: travis report. The Also: Thanks for this. I have to admit I didn't know one could do |
This reverts commit 792fe32. Most of the speed-up comes from removing the unneeded import and the unrolling so no big deal.
I undid the last two commits with the infinity stuff. Those didn't affect the speed of the code as much as the rest. Lost just 5 out of the 30 percent speed-up. Those unit tests are kind of broken anyway. They test the case where MinMax3D is called with a
I would expect that the None means no data so size would be 1x1x1. Instead, the y size was set to zero. This is for the new and old code. So really, this function doesn't work properly with 5% isn't that much but on RPi is can feel like a lot! If you want it done, let me know and I'll make another PR. |
I agree, looking at those tests now I'm not entirely sure what's up there either. I'll happily accept another PR that gets rid of anything senseless there ;) |
to a large audience (ideally all users of OctoPrint)
made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a
Brainstorming ticket
a bug fix for an issue present in the current stable version (no PRs
against master or anything else please)
(no PRs from your version of master, maintenance or devel please),
e.g. dev/my_new_feature or fix/my_bugfix
no dead code, ideally only one commit - rebase and squash your PR
if necessary!
.less source files, not the .css files (those are generated with
lessc)
have added unit tests
nothing broke
What does this PR do and why is it necessary?
Increase gcode analysis speed by around 30%
How was it tested? How can it be tested by the reviewer?
Run this command with and without the patch:
time python ./src/octoprint/cli/analysis.py --speed-x=6000 --speed-y=6000 --max-t=10 --throttle=0.0 --throttle-lines=100 BIG_GCODE_FILE.gco
You will need to patch in the two lines that were added to analysis.py so that you can run analysis.py. I recommended patching those in, too, because they do no harm and make it easier to profile the analysis. To profile, run:
python -m cProfile -s tottime ./src/octoprint/cli/analysis.py --speed-x=6000 --speed-y=6000 --max-t=10 --throttle=0.0 --throttle-lines=100 BIG_GCODE_FILE.gco | less
Notice that the speed is improved but the output is unaffected.
Any background context you want to provide?
While working on the analysis factory, I noticed that default analysis is very slow and tried to improve it. It would run faster if it were in c but that would be a lot more work. This is a good start.