Adaptive Path/CAM Operation

Here's the place for discussion related to CAM/CNC and the development of the Path module.
kreso-t
Posts: 72
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Postby kreso-t » Thu Sep 13, 2018 5:36 pm

sliptonic wrote:
Thu Sep 13, 2018 3:11 pm
Using the same model at home (AMD FX(tm)-4100 Quad-Core Processor 12GB), I'm seeing this result:

*** Adaptive toolpath processing started...
Tool diam: 6.350000
*** Done. Elapsed: 322.135314 sec

The first 2/3 of the path generate quite fast ~15 seconds. The rest goes very slow. I had htop running and the four CPU cores were bouncing around 17%. Max memory usage for freecad about 30%. System peak memory usage about 6GB of 12GB. Plenty of swap.

I shut down every other application I could and shaved about 10 seconds off the total time.
When I put accuracy to max (slider full to the left) I managed to reproduce this slow down: the first part then goes relatively fast and at the end slows down significantly (i.e. like 10 times slower).

Since I can reproduce it now I will probably be able to fix it. My initial guess is that it is related to size of the model - paths grow to have a lot of points and then clipping slows down. Solution I have in mind is to introduce bounding boxes and process the model box by box, that would limit clipping to smaller area (of fixed size) and then (in theory) speed should not depend on size of the model.

Thx for the feedback,
BR,
K.
kreso-t
Posts: 72
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Postby kreso-t » Fri Sep 14, 2018 8:35 am

kreso-t wrote:
Thu Sep 13, 2018 5:36 pm
sliptonic wrote:
Thu Sep 13, 2018 3:11 pm
Using the same model at home (AMD FX(tm)-4100 Quad-Core Processor 12GB), I'm seeing this result:

*** Adaptive toolpath processing started...
Tool diam: 6.350000
*** Done. Elapsed: 322.135314 sec

The first 2/3 of the path generate quite fast ~15 seconds. The rest goes very slow. I had htop running and the four CPU cores were bouncing around 17%. Max memory usage for freecad about 30%. System peak memory usage about 6GB of 12GB. Plenty of swap.

I shut down every other application I could and shaved about 10 seconds off the total time.
When I put accuracy to max (slider full to the left) I managed to reproduce this slow down: the first part then goes relatively fast and at the end slows down significantly (i.e. like 10 times slower).

Since I can reproduce it now I will probably be able to fix it. My initial guess is that it is related to size of the model - paths grow to have a lot of points and then clipping slows down. Solution I have in mind is to introduce bounding boxes and process the model box by box, that would limit clipping to smaller area (of fixed size) and then (in theory) speed should not depend on size of the model.

Thx for the feedback,
BR,
K.
With which accuracy setting are you getting those results?
User avatar
sliptonic
Posts: 1231
Joined: Tue Oct 25, 2011 10:46 pm

Re: Adaptive Path/CAM Operation

Postby sliptonic » Fri Sep 14, 2018 12:05 pm

kreso-t wrote:
Fri Sep 14, 2018 8:35 am
With which accuracy setting are you getting those results?
The default
kreso-t
Posts: 72
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Postby kreso-t » Sat Sep 15, 2018 10:12 pm

sliptonic wrote:
Fri Sep 14, 2018 12:05 pm
kreso-t wrote:
Fri Sep 14, 2018 8:35 am
With which accuracy setting are you getting those results?
The default
Added the performance optimizations for larger models.

On my PC your model is now processed in the range from 4 sec (min accuracy), 6 sec (default accuracy), 32 sec (max accuracy)
for comparison the same model with the previous version ranged from 13 sec (min accuracy) to 600 sec. (max accuracy)

So performance should now be more stable, not so dependent on the settings and model size. For small models it is about the same as before, maybe a little better.

Besides adding bounding boxes had to also change how the tool down linking paths are resolved, previous version was based on offsets which tend to be slow for larger polygons with many points. Also this new linking alg. should be better in resolving the shortest linking path.

these changes are pushed to separate branch in my git profile https://github.com/kreso-t/FreeCAD/tree/PathAdaptive

BR,
K.
User avatar
sliptonic
Posts: 1231
Joined: Tue Oct 25, 2011 10:46 pm

Re: Adaptive Path/CAM Operation

Postby sliptonic » Sun Sep 16, 2018 3:23 pm

Now that your first round of adaptive has been merged into master, will you please rebase your PathAdaptive branch or do additional development in a new branch? If I try to merge your latest changes to test, I get a merge conflict with master.
kreso-t
Posts: 72
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Postby kreso-t » Sun Sep 16, 2018 8:44 pm

sliptonic wrote:
Sun Sep 16, 2018 3:23 pm
Now that your first round of adaptive has been merged into master, will you please rebase your PathAdaptive branch or do additional development in a new branch? If I try to merge your latest changes to test, I get a merge conflict with master.
Hi, I've rebased it, now it's in sync with master + one commit ahead (containing those changes and manually merged changes from master i.e. automatic spelling and white space fixes). I did regression tests with all models I previously used for testing and it all still looks OK (only faster), so I submitted PR for those changes.

BR,
K.
User avatar
sliptonic
Posts: 1231
Joined: Tue Oct 25, 2011 10:46 pm

Re: Adaptive Path/CAM Operation

Postby sliptonic » Tue Sep 18, 2018 2:53 pm

Very Nice! Huge improvement for me. Even on old-busted computer, less than 30 seconds to build the path. Thank you!
kreso-t
Posts: 72
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Postby kreso-t » Tue Sep 18, 2018 7:22 pm

sliptonic wrote:
Tue Sep 18, 2018 2:53 pm
Very Nice! Huge improvement for me. Even on old-busted computer, less than 30 seconds to build the path. Thank you!
That's good to hear.

In meanwhile I managed to squeeze some 20-30 percent more. Also have some bug fixes i.e. noticed that in some cases it may happen to approach into the cut too close with rapid move, it's fixed now. I submitted new PR for this.

BR,
K.
kreso-t
Posts: 72
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Postby kreso-t » Sun Sep 23, 2018 7:53 pm

Added some smoothing of linking paths, now it looks like so:
Selection_047.png
Selection_047.png (15.51 KiB) Viewed 22 times
Also I noticed in some rare cases it could happen to leave some internal area uncleared, this is also fixed now.

BR
K.