Recent

Author Topic: Slow editor on Mac  (Read 42004 times)

Hoch

  • New Member
  • *
  • Posts: 35
Re: Slow editor on Mac
« Reply #30 on: February 13, 2014, 09:21:30 pm »
@skalogryz

Thanks for your code!

I'm I supposed to see a timer? If so, I don't see it. I append a screenshot.

@Martin_fr

I disable 'overview gutter' but does not seem to make a difference.

What I see is that when you type moderalty fast in document with a few lines (20) the cpu usage is more or less 10%
Which is normal. When the document is long, a unit of 1250 lines, the cpu usage goes up to 20-30%.

It is strange but I can live with this.

As you say, scrolling with the slider or mousewheel is a real issue.

Thanks and greetings! :)

Hoch.


skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #31 on: February 13, 2014, 09:55:04 pm »
@skalogryz
I'm I supposed to see a timer? If so, I don't see it. I append a screenshot.
No timer show should up. I was curious about the CPU usage.
The time is there on the page and it invalidates/repaints the whole form every 67 mls.

There're 2 types of rendering text. TextOut and ExtTextOut. TextOut is supposed to be faster and less CPU expensive.

Another thing I expect is when you select ExtTextOut your CPU usage should be the same or higher than when you've the Lazarus editor opened.
(Please note that this test form size needs to be resized to match the source editor).

What I'm trying to do is to figure out the slowest part of the text rendering.

Hoch

  • New Member
  • *
  • Posts: 35
Re: Slow editor on Mac
« Reply #32 on: February 13, 2014, 11:20:16 pm »
@skalogryz

TextOut is marginally faster, 71-72% vs 74-75% for ExtTextOut.

With the patch issued here the Lazarus editor has a near 0 cpu usage except when you scroll.
Seems a stable patch. Should go into 1.2.

Thanks and greetings! :)

Hoch.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #33 on: February 14, 2014, 12:10:30 am »
You refer to the patch I posted (the one that is in trunk already)?

You said cpu also depends on size of unit. Please compare:

When the editor is scrolled all to the end of the file (at least 1000 lines in file)
- edit the last visible line in the editor
- edit the first visible line in the editor

Same when the editor is scrolled to the top of the unit

DO those with and without the overview-gutter, please.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #34 on: February 14, 2014, 05:43:12 am »
@Hoch, @Martin_fr
what is your OSX version?

@Hoch,
If you select No Paint, what's the CPU usage? (please note that the form is still invalidated by the timer)
« Last Edit: February 14, 2014, 05:44:59 am by skalogryz »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #35 on: February 15, 2014, 05:09:02 pm »
Well, it's quite obvious that the text rendering is extremely slow in Carbon.

As an example the same test on Windows consumes at around 1%-2% of CPU (Intel Core(TM) 2CPU 2Ghz).
That's with ClearType enabled (ClearType acts pretty much the same as OSX default font anti-aliasing). Also, even if antialiasing is disabled for Carbon the CPU consumption is still higher.

Looking at the carbon code, I can see a lot of objects are being reallocated, so I'll try to improve the performance by caching some of them.

Another thing that **might** help is to rewrite the rendering engine, that's based on ATSU now (for OSX 10.4 compatibility) to CoreText. Both APIs are deprecated anyway with the whole Carbon. But ATSU is more deprecated :)
« Last Edit: February 15, 2014, 05:11:42 pm by skalogryz »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #36 on: February 18, 2014, 05:48:36 am »
Hoch, could you please run this test. Please compare CPU for "Quartz 2D" and "CoreText" (they should be the same) to the "TextOut"

Hoch

  • New Member
  • *
  • Posts: 35
Re: Slow editor on Mac
« Reply #37 on: March 17, 2014, 12:01:12 pm »
Martin_fr & skalogryz,

Sorry for the delay. I had a very busy month and also, I'm not receiving the emails notifications from the forum…? So I thought that there were no new answers to this topic.

@ Martin_fr
Cpu usage of character drawing while typing is high but I can live with that.
What I think is critical and needs a fix, and maybe related, is the scrolling issue on Mac OS X. It is slow, jumpy and consumes a lot of cpu.

@scalogryz, my OSX version is 10.6.8.

I ran your last test and cpu usage is:

. No Paint: 11%

. TextOut: 73%-79%

. ExtTextOut: 68%-77%

. Quarz2D: 63%-76%

. CoreText: 75% (steady. But shows a white screen)

...Overall very similar.

Thank you and greetings! :)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #38 on: March 17, 2014, 02:41:56 pm »
Thanks for testing. No sure why CoreText would show you blank screen.

...Overall very similar.
Well, it appears that without any kind of caching we won't get any better results from Mac.
With that said, it appears that large scrolling and/or resizing would always end up in high CPU usage (since cache would need to be refreshed at all times).

Hoch

  • New Member
  • *
  • Posts: 35
Re: Slow editor on Mac
« Reply #39 on: March 17, 2014, 04:25:06 pm »
@skalogryz,

So, You mean that the slowness is in the Mac OS libraries and how they handle text?

This looks strange to me... Obviously there are other Mac OS applications that don't have this scrolling issues...

Thanx and greetings! :)

Hoch.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #40 on: March 17, 2014, 04:45:38 pm »
So, You mean that the slowness is in the Mac OS libraries and how they handle text?
No. It's not an issue with OSX, it's more an issue with LCL (and how LCL treats the text and text drawing).
OSX itself encourages "caching" of text-object used for rending. But in LCL there's no such "text objects".

This looks strange to me... Obviously there are other Mac OS applications that don't have this scrolling issues...
Please give an example.
The app should contain the same amount of text though as SynEdit. (I believe just copying a unit text and adjusting the font size to match Lazarus IDE should be enough for testing).


Hoch

  • New Member
  • *
  • Posts: 35
Re: Slow editor on Mac
« Reply #41 on: March 17, 2014, 05:23:56 pm »
@skalogryz,

Ok. Thanks for the explanation.

So no way of fixing this in LCL? Maybe too complex?...

By other apps I meant, those outside of free pascal (browsers, openoffice, etc.)

Thanks and greetings! :)

Hoch.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Slow editor on Mac
« Reply #42 on: March 17, 2014, 05:31:00 pm »
So no way of fixing this in LCL? Maybe too complex?...
Still should be possible. Again caching should improve the performance somehow.

By other apps I meant, those outside of free pascal (browsers, openoffice, etc.)
How about less text-layout sophisticated :) Such as Xcode, TextEdit? What's the CPU usage for them on scrolling (scrolling by dragging scrollbar from top to bottom)?

Hoch

  • New Member
  • *
  • Posts: 35
Re: Slow editor on Mac
« Reply #43 on: March 17, 2014, 08:02:26 pm »
@skalogryz,

If I scroll up and down a pas file of 4.300 lines, same window size, using the slider, with more or less the same scroll speed, I get the following cpu usage:

. TextEdit: 18%-22%
. Lazarus editor: 65%-70%

No Xcode, sorry.

Greetings! :)

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #44 on: May 16, 2014, 10:29:28 am »
I can confirm that the issue is still present.
Any info about fixing it?

 

TinyPortal © 2005-2018