Pocket operation performance

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Pocket operation performance

Post by etrombly »

I was trying to pocket and the dialog was very slow to come up. I did some profiling on it and all the time is spent in checking if a point is inside the shape in _getDirectedNormal in PathPocketShape.py. This is called by getWire. From testing with a few different settings and different shapes getWire has always returned None. Is getWire not functioning as intended? Or am I not using the correct settings to create an extension wire? If the default settings usually return None, can we disable this check by default? There were roughly 400 edges in the faces I was trying to pocket, isInside is called twice per edge, and takes .15 seconds on my machine, so over 2 minutes. I changed _getDirectedNormal to just return None and it finishes almost instantly with the same results.

OS: Arch Linux (kde//usr/share/xsessions/i3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22198 (Git)
Build type: Release
Branch: master
Hash: 76e74294894bbce46d006e149315c6274d206278
Python version: 3.8.5
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: Pocket operation performance

Post by freman »

Hi etrombly. Thanks for taking the effort to dig into these issues of sluggish performance. Sadly, I cannot answer any of your very good questions. It's a shame that after 170 views , not one person has been able to reply.

Can you briefly outline how you are profiling this. It seems little attention has been given to avoiding performance and memory issues and that would be worth looking into.
chrisb
Veteran
Posts: 54302
Joined: Tue Mar 17, 2015 9:14 am

Re: Pocket operation performance

Post by chrisb »

One of the contributors of that file may know:
mlampert wrote: pinged by pinger macro
Russ4262 wrote: pinged by pinger macro
sliptonic wrote: pinged by pinger macro
luzpaz wrote:Kunda1, are you luzpaz?
Who is Schildkroet?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 54302
Joined: Tue Mar 17, 2015 9:14 am

Re: Pocket operation performance

Post by chrisb »

Wsk8 wrote:Are you Schildkroet?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Pocket operation performance

Post by Kunda1 »

luzpaz wrote:Kunda1, are you luzpaz?
Yes.
Link to file would be nice :)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
chrisb
Veteran
Posts: 54302
Joined: Tue Mar 17, 2015 9:14 am

Re: Pocket operation performance

Post by chrisb »

Sorry, I must have searched the wrong file in my previous posts. Authors of https://github.com/FreeCAD/FreeCAD/blob ... hapeGui.py are
mlampert
sliptonic
(etromply)
dubstar-04 wrote:dubstar-04
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Pocket operation performance

Post by etrombly »

I've been using a combination of PathLog.warning for print debugging and my instructions here https://forum.freecadweb.org/viewtopic.php?f=10&t=44785 for performance analysis.

The main issue is in this file https://github.com/FreeCAD/FreeCAD/blob ... etShape.py In the _getDirectedNormal function which is called by _getDirection and getWire. It seems like neither _getDirection or getWire ever return an actual wire from the limited testing I did.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Pocket operation performance

Post by GeneFC »

freman wrote: Sun Aug 16, 2020 7:59 am It's a shame that after 170 views , not one person has been able to reply.
I read the original post,, but I have not seen that sort of problem, so there was nothing to reply.

This is one of those cases where an example file is *really* needed.

Gene
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Pocket operation performance

Post by etrombly »

Here's the file I was testing. Just double click on Pocket_Shape to bring up the pocket dialog, it takes about 2 minutes on my computer. If you edit PathPocketShape.py and under def _getDirectedNormal(self, p0, normal): add "return None", it will open pretty much instantly. I'm just trying to figure out if there is a way we can disable that check by default unless it's needed. The code isn't really commented, so I was trying to figure out when getDirectedNormal would actually return something, because it returned None anyway in all my testing (which was just a few shapes and settings, not totally extensive).

https://filebin.net/1ovzn6i4s9q1aev3/Be ... t=lyo4tyln
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Pocket operation performance

Post by GeneFC »

I can verify that it took a couple of minutes to open, and it was more or less instant when the "normal" checking was bypassed. I have no idea what is happening or why it works that way.

Thanks for the file.

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22261 (Git)
Build type: Release
Branch: master
Hash: 1c432fd6170b7904592a224194e42d3c566707a6
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)

Gene
Post Reply