Bug 576941 - Execution of GDI/GDI+ functions is slower under Windows 10 than Windows 7
Summary: Execution of GDI/GDI+ functions is slower under Windows 10 than Windows 7
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7.2   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-28 10:59 EDT by Stephane Libois CLA
Modified: 2021-10-30 16:47 EDT (History)
3 users (show)

See Also:


Attachments
Source code of our benchmark tool (86.29 KB, application/x-zip-compressed)
2021-10-29 09:22 EDT, Stephane Libois CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephane Libois CLA 2021-10-28 10:59:50 EDT
Context: Train traffic management system has a fat client developed with Eclipse RCP Workbench 3.7.2. Graphical views of the client make at high frequency redraws of all graphical objects (images, lines, polygons, rectangles, texts,...).

Under Windows 7 update 2018 we have following results (average time in milliseconds):

Canvas.drawText() : 0,06
Canvas.drawImage() : 0,08
Canvas.drawPolygon() : 0,02
Canvas.fillPolygon() : 0,02

Under Windows 7 update 2021 we have following results (average time in milliseconds):

Canvas.drawText() : 0,10
Canvas.drawImage() : 2,35
Canvas.drawPolygon() : 0,03
Canvas.fillPolygon() : 0,07

Under Windows 10 update 2021 we have following results (average time in milliseconds):

Canvas.drawText() : 0,11
Canvas.drawImage() : 3,55
Canvas.drawPolygon() : 0,05
Canvas.fillPolygon() : 0,05

Do you known if someone else has already experienced the same problems? Is there something that I can do to accelerate these functions ?

We realized a benchmark program by using Eclipse RCP 3.7.2 to compute these results. If needed, we can upload it.

Thanks in advance.
Comment 1 Andrey Loskutov CLA 2021-10-28 11:08:30 EDT
Don't get me wrong, but Eclipse 3.7.2 isn't supported since very long time.
Could you try to port your application on 4.21 (or at least to use SWT from that version) and check if that would improve performance?
Comment 2 Stephane Libois CLA 2021-10-29 09:00:16 EDT
Hello,

Thank you for your reply.

We have updated our benchmark program with Eclipse RCP 4.21. Results are similar:

Under Windows 7 update 2018 we have following results (average time in milliseconds):

Canvas.drawText() : 0,06
Canvas.drawImage() : 0,75 (Remark: 0,08 was incorrect, should be 0,80)
Canvas.drawPolygon() : 0,02
Canvas.fillPolygon() : 0,02

Under Windows 7 update 2021 we have following results (average time in milliseconds):

Canvas.drawText() : 0,09
Canvas.drawImage() : 1,98
Canvas.drawPolygon() : 0,04
Canvas.fillPolygon() : 0,07

Under Windows 10 update 2021 we have following results (average time in milliseconds):

Canvas.drawText() : 0,11
Canvas.drawImage() : 3,23
Canvas.drawPolygon() : 0,05
Canvas.fillPolygon() : 0,05

Kind regards.
Comment 3 Andrey Loskutov CLA 2021-10-29 09:12:08 EDT
(In reply to Stephane Libois from comment #2)
> We have updated our benchmark program with Eclipse RCP 4.21. Results are
> similar

Looks like Canvas.drawText() & Canvas.drawImage() are still slower in 4.21 on Win 10 compared to Win 7.

Any chance to attach the benchmark here, or to profile & attach profiling results?

@Alexander & Jörg: may be interesting for you, I do not plan to look into this further.
Comment 4 Stephane Libois CLA 2021-10-29 09:22:54 EDT
Created attachment 287399 [details]
Source code of our benchmark tool

Here is our java code of benchmark tool.
Thanks for your help.
Comment 5 Alexandr Miloslavskiy CLA 2021-10-30 16:47:07 EDT
I had a look.

Your benchmark doesn't set 'SWT.DOUBLE_BUFFERED' to the Control that is being painted. Hence some flashing and a 25% slowdown. Not sure if this is a problem of your test or the app behind it. Anyways, just fix that.

Next, SWT is clearly not very efficient at drawing images.

Here's what happens for an image that has transparency:
----
34.7% - 1,525 ms org.eclipse.swt.graphics.GC.drawBitmap
  33.4% - 1,470 ms org.eclipse.swt.graphics.GC.drawBitmapAlpha
    5.6% - 244 ms org.eclipse.swt.internal.win32.OS.AlphaBlend
    5.1% - 225 ms org.eclipse.swt.internal.win32.OS.DeleteDC
    5.0% - 219 ms org.eclipse.swt.internal.win32.OS.DeleteObject
    4.9% - 214 ms org.eclipse.swt.graphics.Image.createDIB
    4.7% - 206 ms org.eclipse.swt.internal.win32.OS.SelectObject
    3.2% - 140 ms org.eclipse.swt.internal.win32.OS.CreateCompatibleDC
    3.2% - 139 ms org.eclipse.swt.internal.win32.OS.BitBlt
    0.9% - 39 ms org.eclipse.swt.internal.win32.OS.GetObject
    0.2% - 10 ms org.eclipse.swt.internal.win32.OS.MoveMemory(long, byte[ ], int)
    0.1% - 5 ms org.eclipse.swt.internal.win32.OS.GetDeviceCaps
    0.1% - 5 ms org.eclipse.swt.internal.win32.OS.MoveMemory(byte[ ], long, int)
----

There, 'AlphaBlend' is actual painting, and everything else is preparing Image to be painted. This could be done just once, yet alas, it's done every time, which is some 6x slower than it could be.

The image without transparency is some 3x faster than the same image with transparency.

Here's what happens in this case (test .png re-saved as .bmp):
----
21.3% - 1,416 ms org.eclipse.swt.graphics.GC.drawBitmap
  6.8% - 455 ms org.eclipse.swt.internal.win32.OS.DeleteDC
  6.0% - 401 ms org.eclipse.swt.internal.win32.OS.BitBlt
  4.3% - 287 ms org.eclipse.swt.internal.win32.OS.CreateCompatibleDC
  3.8% - 252 ms org.eclipse.swt.internal.win32.OS.SelectObject
----

Again, 'BitBlt' is the actual painting and the rest are preparations.
It could be 3.5x faster if preparations were only done once.

Why you see a difference between Win7 and Win10 is a mystery of sorts, but I suspect that you're simply running it on different hardware.

I think that this case is not interesting to our product (as we're not painting a lot of images), so I can't spend time optimizing that, sorry.