TechDraw Multithread Testing

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

TechDraw Multithread Testing

Post by wandererfan »

A version of TD which uses separate threads for HLR and face finding is available here: https://github.com/WandererFan/FreeCAD/ ... rThreadrc1 and via PR#7224.

Help with testing and feedback would be very much appreciated. @kunda1, could you please do your Snap voodoo for the benefit of those who can not build there own version?

Expectation Management
- the actual OCC HLR algorithm is still single threaded, as is face finding, so if you have a single complex view you will not see any speed increase.
- if you have a number of views in your document, you should see some improvement in loading speed as the views will be redrawn in parallel.
- if you have only simple views, it is possible that this version may be slower than the original.
- the Gui is no longer locked during HLR, so you can do other work while waiting.
- the testing so far has been mostly loading documents. There may be issues in creating views, but I haven't seen any yet.
- progress reporting is very rudimentary, just messages in the Report View.

Thanks for your help.
Last edited by Kunda1 on Mon Sep 12, 2022 12:31 pm, edited 1 time in total.
Reason: Added TechDraw to title to distinguish from Multithreading in general
user1234
Veteran
Posts: 3261
Joined: Mon Jul 11, 2016 5:08 pm

Re: Multithread Testing

Post by user1234 »

Thanks! I will surely give feedback!

Greetings
user1234
user1234
Veteran
Posts: 3261
Joined: Mon Jul 11, 2016 5:08 pm

Re: Multithread Testing

Post by user1234 »

I made a test on an assembly drawing, 1 view, 2 sections.


----------
branch master
drawing setting: when file loaded, drawing is empty (keep updated = false)
clicking redraw page
time: ~2:20
no multicore, mouse have loading sign, while mouse clicking it does not respond, can move with the mouse
result is ok
toggle keep updated (is now true)
drawing load again (have not got the time, did not expect that it reloads anything, since i did not anything)
sometimes multicore (max. 3 cores to 100%)
result is always ok
----------
branch hlrThreadrc1
drawing setting: when file loaded, drawing is empty (keep updated = false) (same as before)
clicking redraw page
time: ~2:10
no multicore, mouse have no loading sign, while mouse clicking it does not respond, can move with the mouse
result is not ok, dimensions are missing (see later)
toggle keep updated (is now true)
drawing load again
sometimes multicore (max. 3 cores to 100%)
result is not ok, dimensions are missing (see later)
----------
branch master
drawing setting: when file loaded, drawing loads (keep updated = true)
time: 3:30 (why slower? i do not know, parts need only 6s to load)
no multicore, mouse have loading sign, while mouse clicking it does not respond, can move with the mouse
result is ok
----------
branch hlrThreadrc1
drawing setting: when file loaded, drawing loads (keep updated = true) (same as before)
time: 2:45, a little bit faster, but after the drawing occur, it loads after that around 30s to get the mouse again, so the time is pretty the same as the master
multicore, mouse have no loading sign, while mouse clicking it does not respond, can move with the mouse
result is not ok, dimensions are missing (see later)
----------

The dimensions are missing in the hlrThreadrc1 branch. The occur when you click on the dimensions in the tree, but also the dimensions are wrong (mostly on x=0 and y=0), see video.
1.webm
(87.15 KiB) Downloaded 76 times

Yes i know, that is only a fast'n'dirty test. I hopefully can test it later better.


Greetings
user1234
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Multithread Testing

Post by wandererfan »

user1234 wrote: Wed Jul 20, 2022 11:38 pm mouse have no loading sign, while mouse clicking it does not respond, can move with the mouse
result is not ok, dimensions are missing (see later)
Please try using regular views. It appears sections and details still need some work.
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Multithread Testing

Post by wandererfan »

Pushed a new version this morning. Dimensions in Sections and Details should work properly in this version.

Still looking at whether or not to split the cutting operations for Sections and Details out into a separate thread.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Multithread Testing

Post by Kunda1 »

wandererfan wrote: Wed Jul 20, 2022 3:09 pm Help with testing and feedback would be very much appreciated. @kunda1, could you please do your Snap voodoo for the benefit of those who can not build there own version?
Working on the snap now. Will update soon.
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
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Multithread Testing

Post by wandererfan »

A new version is available in the same location. It now runs the section cut and detail common operations in separate threads.

I imagine this messes up the snap version @Kunda1 is preparing.

I don't have good timing numbers for the TD activity, but 1 did see 4 cores at 100% when loading a test file.

There is a relatively short period where the Gui is locked out, but I haven't found it yet and it doesn't last long.
user1234
Veteran
Posts: 3261
Joined: Mon Jul 11, 2016 5:08 pm

Re: Multithread Testing

Post by user1234 »

wandererfan wrote: Fri Jul 22, 2022 9:20 pm A new version is available in the same location. It now runs the section cut and detail common operations in separate threads.
Thanks! I compiled it and run only once. It is a little bit faster, but still some issues. Since it is pretty hard to test (because every run takes a long time), i will try to write a test macro.

Greetings
user1234
user1234
Veteran
Posts: 3261
Joined: Mon Jul 11, 2016 5:08 pm

Re: Multithread Testing

Post by user1234 »

A small test only for views: no section, no dimensions, views are prepared. 10 views.

master: 133s
redraw page blocks FreeCAD

hlrThreadrc1: 24s!
redraw page blocks not FreeCAD

Improvement: 5.5 times!
(Just saying, that while creating the views, it is feels much faster, because FreeCAD does not block).

But one thing happens only one time, that 1 view does not update.

1.png
1.png (352.35 KiB) Viewed 3519 times

Greetings
user1234
user1234
Veteran
Posts: 3261
Joined: Mon Jul 11, 2016 5:08 pm

Re: Multithread Testing

Post by user1234 »

A test while loading the file. It does not respect the Auto Distribute while loading. When refreshing, then it does distribute. But then you see, when do something while calculating, it one view does not work. I think this is because something is not thread save, because sometimes it crashes. Also when you click on something like Open (File) while calculating, FreeCAD freezes or, better said, the GUI is not accessible, because the the CPU load is zero. There is nothing about that to find in the log.

1.webm
(750.58 KiB) Downloaded 75 times


Here a log when it crashes:

Code: Select all

Log: VPP::getMDIViewPage has no m_mdiView!
Msg: ProjItem is finding hidden lines
Err: Program received signal SIGSEGV, Segmentation fault.
Err: #0  /lib/x86_64-linux-gnu/libc.so.6(+0x3bd60) [0x7fdeec40ad60]
Err: #1  0x7fdd760e8503 in TechDraw::GeometryObject::addFaceGeom(std::shared_ptr<TechDraw::Face>) from /home/user/Programs/FreeCADhlrThreadrc1/build/Mod/TechDraw/TechDraw.so+0x3
Err: #2  0x7fdd7607806c in TechDraw::DrawViewPart::extractFaces() from /home/user/Programs/FreeCADhlrThreadrc1/build/Mod/TechDraw/TechDraw.so+0xaac
Err: #3  0x7fdd76078b85 in non-virtual thunk to QtConcurrent::RunFunctionTask<void>::run() from /home/user/Programs/FreeCADhlrThreadrc1/build/Mod/TechDraw/TechDraw.so+0x25
Err: #4  /lib/x86_64-linux-gnu/libQt5Core.so.5(+0xcfed2) [0x7fdeec84aed2]
Err: #5  /lib/x86_64-linux-gnu/libQt5Core.so.5(+0xccbe1) [0x7fdeec847be1]
Err: #6  /lib/x86_64-linux-gnu/libpthread.so.0(+0x8ea7) [0x7fdeec3b5ea7]
Err: #7  /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fdeec4ccdef]
Err: Program received signal SIGSEGV, Segmentation fault.
Err: #0  /lib/x86_64-linux-gnu/libc.so.6(+0x3bd60) [0x7fdeec40ad60]
Err: #1  [0x555877c41a30]

Greetings
user1234

edit: dimensions seems to work (on normal views)
Post Reply