Gui 3d view poor performance (< 3 fps)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
squeaks
Posts: 2
Joined: Wed May 25, 2022 8:41 pm

Gui 3d view poor performance (< 3 fps)

Post by squeaks »

Problem: When creating or moving any objects in the 3d view, the objects move at about 1-2 fps. It makes selecting and dragging an object difficult, because the mouse moves and then the object follows behind it.

Steps I use to reproduce:
1. Start FreeCAD in a console: "QT_QPA_PLATFORM=xcb FreeCAD"
2. Click New Document.
3. Click Create Body.
4. Click Create Sketch.
5. Click XY_Plane. (Sketcher opens)
6. Click Create Circle.
7. Click to place circle center, now frames are low and circle is updated at < 2fps)
8. Move mouse to desired radius, click again to stop updating circle.
9. Click and hold circle center, drag mouse to the right and observe jerky animation.
I know it's a bug because the Radeon Sapphire R9 390 video card is a relatively recent card. I have checked freecad on my system with an Nvidia Asus gtx 1070, whose 3d view performance matches the refresh rate of my monitor. This bug occurs both in KDE plasma (wayland) on Arch, and Xfce (xorg) on Manjaro. I've tried radeon drivers, amdgpu driver, amdgpu driver with amdgpu.dc=0, separately amdgpu.dmp=0, also amdgpu.exp_hw_support=1. I've tried with only one monitor plugged in.

One thing I haven't tried is I have the r9 390 in the lower pcie slot, and the 1070 in the first pcie slot. However, given everything else works correctly running on the 390 I don't think it should be a problem.

I've tried blender and librecad with no problems.

The problem has been tested to occur in the following versions:
FreeCAD_weekly-builds-28918-2022-05-22-conda-Linux-x86_64-py39.AppImage
AUR FreeCAD 0.20 Revision: 28775 (Git)
Built from source:

Code: Select all

OS: Arch Linux (KDE)
Word size of FreeCAD: 64-bit
Version: 0.20.28928 (Git)
Build type: Debug
Branch: master
Hash: d492ac30838e4fb07b1ce4b378730f2fb38b9ba3
Python 3.10.4, Qt 5.15.4, Coin 4.0.1, OCC 7.5.3
Locale: English/United States (en_US)
Installed mods: 
  * fasteners 0.3.41

Code: Select all

Operating System: Arch Linux
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4
Kernel Version: 5.17.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 62.8 GiB of RAM
Graphics Processor: AMD Radeon R9 390 Series

Code: Select all

[user-arch@antec-arch ~]$ glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: AMD (0x1002)
    Device: AMD HAWAII (LLVM 13.0.1, DRM 2.50, 5.17.9-arch1-1) (0x67b1)
    Version: 22.1.0
    Accelerated: yes
    Video memory: 8192MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 7400 MB, largest block: 7400 MB
    VBO free aux. memory - total: 1982 MB, largest block: 1982 MB
    Texture free memory - total: 7400 MB, largest block: 7400 MB
    Texture free aux. memory - total: 1982 MB, largest block: 1982 MB
    Renderbuffer free memory - total: 7400 MB, largest block: 7400 MB
    Renderbuffer free aux. memory - total: 1982 MB, largest block: 1982 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 8192 MB
    Total available memory: 10235 MB
    Currently available dedicated video memory: 7400 MB
OpenGL vendor string: AMD
OpenGL renderer string: AMD HAWAII (LLVM 13.0.1, DRM 2.50, 5.17.9-arch1-1)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 22.1.0
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 22.1.0
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 22.1.0
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
I found lines like

Code: Select all

Wrn: Accelerator conflict between Std_ViewFitAll (V, F) and Sketcher_ConstrainVertical (V)
to be curious in the FreeCAD.log file.

I find it curious that FreeCAD's pstree output shows many threads when I run the program displaying output to my 390 card. But when I run it to output on the nvidia 1070 card, I only see two threads.

I've attached a file with two straces which were taken with the radeon driver, I will probably attach another with the amdgpu driver. To take the strace, I get the strace command ready in a console, then I prepare a sketch with a single circle. Then I start the strace, I click and hold the center of the circle, then I move the circle and stop, then ctrl-C the strace.

The difference in the straces between amdgpu and radeon would be something like:
"ioctl(9, DRM_IOCTL_AMDGPU_WAIT_CS, 0x7ffc0036bf70) = 0"
instead of
"5865 21:14:47.925761 (+ 0.000012) ioctl(12, DRM_IOCTL_RADEON_GEM_WAIT_IDLE, 0x7ffd18c6e930) = 0 <0.004183>
5865 21:14:47.929988 (+ 0.004228) ioctl(12, DRM_IOCTL_RADEON_GEM_BUSY, 0x7ffd18c6e850) = 0 <0.000016>"

The attached strace is just for the thread of the main process, the one that pgrep -i freecad reports as the process. I could excerpt a second or two of strace with -f (traces children too.).

I think this fellow had a similar problem. I am unable to run old AppImages though.
https://forum.freecadweb.org/viewtopic.php?t=38443

Because this problem occurs with both the amdgpu and radeon drivers, I suspect something else, maybe QT5, or a kernel bug. It seems like something is held up by a futex or a resource being unavailable. Is it possible running the video card through the x570 pcie chipset could be a problem in this corner case for some reason? Can anyone help me track the problem further so I can file a bug report somewhere? Is there a QT6 build of FreeCAD? I can have strace print stack with each call.

Thanks,
Squeaks
Attachments
radeon_390_movecircle_freecad_snip.txt
(860.6 KiB) Downloaded 9 times
radeon_390_children_dmesg.txt
(147.86 KiB) Downloaded 7 times
FreeCAD.log
(15.5 KiB) Downloaded 7 times
squeaks
Posts: 2
Joined: Wed May 25, 2022 8:41 pm

Re: Gui 3d view poor performance (< 3 fps)

Post by squeaks »

I swapped the cards in the pcie slots, I put the 390 into slot 1 and 1070 in slot 2.

The 390's performance improved from ~3 fps to ~6-7 fps.

The #1 slot runs at pcie x16 and slot two is x4.

I'm still looking into things, I think there must be a bug somewhere. I think it's a resource unavailable bug for some reason that is causing the locking resource of the gpu to fail.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Gui 3d view poor performance (< 3 fps)

Post by onekk »

Take in account that there is some problems around with mesa libs (the OpenGL incarnation on Linux), on Arch Linux and a quite old card (a i3-2120 internal graphics) I have to downgrade my mesa to 21.3.7 as 22.0 is creating problems.

I know that my card is old as it is a Gen4 SandyBridge CPU, but maybe it is related not to FC but with the graphics infrascture of Linux, that is farily comlex, and could fail in many places.

"xcb" is not the most performant way to use X.org, from what i know, maybe it is not related but....

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply