Pcbnew very slow loading pcb (with lots of polygons in OpenGL mode)

Bug #1745050 reported by Romain
36
This bug affects 8 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Medium
Tomasz Wlostowski

Bug Description

Using:
Application: kicad
Version: (2018-01-23 revision 975c08c46)-makepkg, release build
Libraries:
    wxWidgets 3.0.3
    libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.60.0
    Curl: 7.54.1
    Compiler: GCC 7.1.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_SPICE=ON

Since a few weeks, Pcbnew has become really slow opening and saving a PCB file. It's worth noting that I've been working with this file for months and never noticed a performance issue before.
Here is a sample project with a (heavy) footprint: a halftone picture of the product designers.
The project takes minutes to save.
I understand that the footprint is big, although I never experienced performance issues before.

Tags: gal opengl
Revision history for this message
Romain (romain145) wrote :
Revision history for this message
Seth Hillbrand (sethh) wrote :

I went back to 413008344 (June) and can confirm a couple aspects of this bug report.

1) Opening
- Starting pcbnew in OpenGL canvas takes ~2x as long with current master as it did with 413008344 when the sample project is loaded. All of the extra time occurs with a completely blank screen in pcbnew (no icons).
- Starting pcbnew with Legacy or Cairo canvas is instant for 413008344 using the sample project.
- Starting pcbnew with Legacy or Cairo canvas in current master is also fast (almost instant)

2) Selecting the silkscreen
- Using opengl, selecting the silkscreen locks pcbnew for about 20s. This is the same in master as well as in 413008344.
- Using cairo or legacy, selecting the silkscreen is instant.

3) Saving the file
- Using 413008344, saving is instant, regardless of canvas.
- Using master, saving takes a _long_ time (minutes), regardless of canvas.

4) Closing pcbnew
- Closing pcbnew with the sample project in current master takes ~30s of completely locked window. In fact, X thinks that the application has crashed and offers to kill it for me. This is without changing the board or saving.
- Closing pcbnew in 413008344 is instant.

Changed in kicad:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Seth, many thanks for the detailed report. Is 413008344 the first commit that slowed down pcbnew, or it is just a data point for comparison?

Revision history for this message
jean-pierre charras (jp-charras) wrote :

Hi Orson,

I had a look into this issue.
There are in fact 2 issues:

* Slow when loading the board in OpenGL mode. I do not know why.
Could you have a look into the loading issue? Thanks.

* Slow when saving the board: I am fixing this save issue.
This is due to an inefficient use of DRAWSEGMENT:: GetPolyPoint that creates unnecessary copies of polygon corner lists a lot of time.
And this board uses a lot of polygonal DRAWSEGMENTS.
I am removing these useless copies.

Revision history for this message
Seth Hillbrand (sethh) wrote :

413008344 was just a data point, not the first revision.

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 270a63daace8854f703f3612faa5942a3e3c058c
https://git.launchpad.net/kicad/patch/?id=270a63daace8854f703f3612faa5942a3e3c058c

Changed in kicad:
status: Confirmed → Fix Committed
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

I think it is still very slow in OpenGL, so I set the bugs status to 'Confirmed'.

Changed in kicad:
status: Fix Committed → Confirmed
Revision history for this message
jean-pierre charras (jp-charras) wrote :

Hi Orson,
For my info, are you talking about the first issue (loading time), not fixed?
I am thinking the saving issue is fixed.

Revision history for this message
Romain (romain145) wrote :

I confirm that the saving issue is fixed. Thanks!
The first issue (loading time) is still not fixed.

Revision history for this message
Jon Evans (craftyjon) wrote :

Trace of loading this board on latest master, showing where all the time is taken (DrawPolygon):
https://i.imgur.com/zfJJveU.jpg

Jon Evans (craftyjon)
summary: - Pcbnew very slow saving pcb
+ Pcbnew very slow loading pcb (with lots of polygons in OpenGL mode)
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Jean-Pierre,

Yes, saving is instant now - thank you for fixing this. The report mentions also slow loading time, which is still a problem in OpenGL. We will need to think how to speed up tessellation process.

tags: added: gal opengl
Revision history for this message
Hildo Guillardi Júnior (hildogjr) wrote :

For me the same happens also (too) in Gerber Viewer using OpenGL (https://bugs.launchpad.net/kicad/+bug/1745203). Maybe related?

Revision history for this message
Mitja Nemec (mitjan) wrote :

This might be related.

I am also observing long open times in GAL canvas in 5.0.0-rc2-dev-28-g5f578c884. But just on one of the two machines I am working on (Win7 both of them).

Application: kicad
Version: (5.0.0-rc2-dev-28-g5f578c884), release build
Libraries:
    wxWidgets 3.0.3
    libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.60.0
    Curl: 7.54.1
    Compiler: GCC 7.1.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_SPICE=ON

Revision history for this message
Mitja Nemec (mitjan) wrote :

Sorry to add noise, but I forgot to mention that if you switch to legacy or cairo, then close the pcbnew, open it again (which is fast) and switch to GAL it is way faster than opening in GAL directly.

Revision history for this message
Jon Evans (craftyjon) wrote :

Hi Mitja,

Are you able to share any of the files (either here or in private by email) that are slow to load for you?

Are you saying the same files are slow to load on one machine but fast on the other?

What are the hardware specs on the computers? Is there a big difference?

Changed in kicad:
assignee: nobody → Tomasz Wlostowski (twlostow)
Revision history for this message
Mitja Nemec (mitjan) wrote :
Download full text (3.2 KiB)

Hi, I am attaching a project. The schematics is in process of migration to V5, but you should only need pcb.

Jup. the same project is slow to open on one machine, while fast to open on another machine. Using older revision "r8510.dddaa7e69" from end of September 2017 is fast on both machines.

This is a hardware info where I don't experience any significant delay on pcbnew open. It is a dual display configuration and it does not matter on which display I open it.
Sluzba:

CPU & MEM: i7 2600 8GB
Name ATI Radeon HD 5450
PNP Device ID PCI\VEN_1002&DEV_68F9&SUBSYS_21811462&REV_00\4&62001AA&0&0008
Adapter Type ATI display adapter (0x68F9), ATI Technologies Inc. compatible
Adapter Description ATI Radeon HD 5450
Adapter RAM 512,00 MB (536.870.912 bytes)
Installed Drivers aticfx64.dll,aticfx64.dll,aticfx64.dll,aticfx32,aticfx32,aticfx32,atiumd64.dll,atidxx64.dll,atidxx64.dll,atiumdag,atidxx32,atidxx32,atiumdva,atiumd6a.cap,atitmm64.dll
Driver Version 8.821.0.0
INF File oem3.inf (ati2mtag_EvergreenC section)
Color Planes Not Available
Color Table Entries 4294967296
Resolution 1920 x 1080 x 60 hertz
Bits/Pixel 32
Memory Address 0xD0000000-0xDFFFFFFF
Memory Address 0xFE4E0000-0xFE4FFFFF
I/O Port 0x0000EF00-0x0000EFFF
IRQ Channel IRQ 4294967291
Driver c:\windows\system32\drivers\atikmpag.sys (8.14.1.6187, 292,50 KB (299.520 bytes), 26.1.2011 21:13)

Name Intel(R) HD Graphics
PNP Device ID PCI\VEN_8086&DEV_0102&SUBSYS_307017AA&REV_09\3&11583659&0&10
Adapter Type Intel(R) HD Graphics Family, Intel Corporation compatible
Adapter Description Intel(R) HD Graphics
Adapter RAM (2.017.460.224) bytes
Installed Drivers igdumd64.dll,igd10umd64.dll,igd10umd64.dll,igdumd32,igd10umd32,igd10umd32
Driver Version 9.17.10.3347
INF File oem6.inf (iSNBD0 section)
Color Planes Not Available
Color Table Entries 4294967296
Resolution 1920 x 1080 x 60 hertz
Bits/Pixel 32
Memory Address 0xFE000000-0xFE3FFFFF
Memory Address 0xC0000000-0xCFFFFFFF
I/O Port 0x0000F000-0x0000F03F
IRQ Channel IRQ 4294967293
I/O Port 0x000003B0-0x000003DF
I/O Port 0x000003C0-0x000003DF
Memory Address 0xA0000-0xBFFFF
Driver c:\windows\system32\drivers\igdkmd64.sys (9.17.10.3347, 5,11 MB (5.363.200 bytes), 29.1.2014 22:02)

This is hardware info where I experience significant delay opening in GAL. If opening in legacy or Cairo and then switching to GAL there are no significant delays.

CPU & MEM: i3 4170 6GB
Name Intel(R) HD Graphics 4400
PNP Device ID PCI\VEN_8086&DEV_041E&SUBSYS_041E1849&REV_06\3&11583659&0&10
Adapter Type Intel(R) HD Graphics Family, Intel Corporation compatible
Adapter Description Intel(R) HD Graphics 4400
Adapter RAM (1.073.741.824) bytes
Installed Drivers igdumdim64.dll,igd10iumd64.dll,igd10iumd64.dll,igdumdim32,igd10iumd32,igd10iumd32
Driver Version 10.18.10.3383
INF File oem102.inf (iHSWD_w7 section)
Color Planes Not Available
Color Table Entries 4294967296
Resolution 1280 x 1024 x 60 hertz
Bits/Pixel 32
Memory Address 0xF0000000-0xF03FFFFF
Memory Address 0xE0000000-0xEFFFFFFF
I/O Port 0x0000F000-0x0000F03F
IRQ Channel IRQ 4294967291
I/O Port 0x000003B0-0x000003BB
I/O Port 0x000003C0-0x000003DF
Memory Address 0xA0000-0xBFFFF
Driver c:\windows\system32\drivers\igdkmd64.sys (1...

Read more...

Revision history for this message
Mitja Nemec (mitjan) wrote :

Some additional observations. Performing operations on many items at once is also slow. E.g. If I select half of the board and hit delete I experience a small delay in GAL. But if I hit undo after, the delay is around 10 seconds. In Cairo there is no delay.

The funny thing is, that if I delete in Cairo, switch to GAL and then Undo, there is no delay. The delay is only present if I delete and undo in GAL. Even if I delete in GAL, switch to Cairo and back to GAL and then Undo, there is no delay.

Revision history for this message
Eldar Khayrullin (eldar) wrote :

I confirm the last message. But I don't see any big difference bettween OpenGL and Cairo (slow delete/undo big group of elements). Legacy works OK.

Revision history for this message
Eldar Khayrullin (eldar) wrote :

Application: kicad
Version: 5.0.0-rc2-dev-unknown-aeae32b~62~ubuntu17.10.1, release build
Libraries:
    wxWidgets 3.0.3
    libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 (+libidn2/2.0.2) librtmp/2.3
Platform: Linux 4.13.0-36-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.62.0
    Curl: 7.55.1
    Compiler: GCC 7.2.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_SPICE=ON

Revision history for this message
Eldar Khayrullin (eldar) wrote :

I say about group of graphic lines imported from a DXF file

Revision history for this message
jean-pierre charras (jp-charras) wrote :

I am thinking commit 0bceb69f should have fixed the slowness loading the sample board.

Others sources of slowness are already fixed.
So I set the bug status to committed.

Changed in kicad:
status: Confirmed → Fix Committed
milestone: none → 5.1.0
Revision history for this message
Seth Hillbrand (sethh) wrote :

The second board definitely is fixed.

The first with the halftone image could still be improved although that is quite a corner case. I think fixing that would require changing the OpenGL pipeline to avoid the fixed function calls

Revision history for this message
jean-pierre charras (jp-charras) wrote :

I had to revert commit 0bceb69f, because it was not working with all polygons.

I agree with Seth: The first with the halftone image is really a corner case.
In fact the loading time is mainly spent to calculate the polygon triangulation by the GLU tesselator to fill the polygons (that have tens of thousands of vertexes).
This is Opengl specific.

Revision history for this message
Seth Hillbrand (sethh) wrote :

That was lp:1806411?

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.