Bug 114392 - MacOS: Increased CPU usage while typing
Summary: MacOS: Increased CPU usage while typing
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.0.3 release
Hardware: All macOS (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: perf
Depends on:
Blocks: MacOS-Performance
  Show dependency treegraph
 
Reported: 2017-12-10 19:51 UTC by Telesto
Modified: 2026-07-06 03:13 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2017-12-10 19:51:16 UTC
Description:
Probably an implementation detail, but the CPU time spend for screen rendering while typing has increased (not noticeable in daily usage)  Likely doubled, but not sure (hard the measure). It seems to spend more time with alpha bitmaps handling.

Not sure what the impact is for a high res screen..

Steps to Reproduce:
1. Launch LibreOffice 5.4 or 6b2 or 6.1 alpha with Instrument using the time profile
2. Start typing 4 rows of text.
3. Create also a time profile using Libreoffice 5.3.7.2
4. Compare both of the time profiles
* the 6.0 profile will be spiky/ 5.3. flatter..
* . Drill Down to SwRootFrame::PaintSwFrame(OutputDevice&, SwRect const&, SwPrintData const*) const en compare the time spend while there. 
5. Compare the results with LibreOffice 5.3.7.2


Actual Results:  
It looks like more time is spend rendering 

Expected Results:
The big question.. 


Reproducible: Always


User Profile Reset: No



Additional Info:
Found in
Version: 6.1.0.0.alpha0+
Build ID: d46dc8e547810208287aab77f0313f1971901464
CPU threads: 4; OS: Mac OS X 10.12.6; UI render: default; 
TinderBox: MacOSX-x86_64@49-TDF, Branch:master, Time: 2017-12-08_10:35:46
Locale: nl-NL (nl_NL.UTF-8); Calc: group threaded

and in 
5.4.0.3

but not in 
5.3.7.2

A possible candidate:
https://cgit.freedesktop.org/libreoffice/core/commit/?h=libreoffice-5-4&id=b5699cd01b6a52906880c107bac6f3802ea7353d


User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Comment 1 Alex Thurgood 2017-12-13 08:49:51 UTC
Confirming with my master build 6.0alpha1.

The main lag seems to appear for me in the handling in bitmap.cxx, line 945:

    Bitmap aBmp(GetBitmap(aDstRect.TopLeft(), aDstRect.GetSize()));

which is called by function :

void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap, const AlphaMask& rAlpha, tools::Rectangle aDstRect, tools::Rectangle aBmpRect, Size& aOutSize, Point& aOutPoint)
Comment 2 QA Administrators 2019-03-03 03:41:29 UTC Comment hidden (obsolete)
Comment 3 QA Administrators 2021-03-03 03:52:53 UTC Comment hidden (obsolete)
Comment 4 Luboš Luňák 2021-11-18 14:09:03 UTC
Please try this with a developer build from https://dev-builds.libreoffice.org/daily/master/ [*]. Check with option Tools->Options->View->Use Skia for all rendering both enabled and disabled, and when enabled with both Force Skia software rendering enabled and disabled.

And is this a duplicate of bug #120727?

[*] Today's build may still have some rendering problems in dialogs, so tomorrow's should be better, but even today's should be usable for testing this bug.
Comment 5 Telesto 2022-12-26 12:32:53 UTC
Well unsure what was about exactly. 

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 8635c9aa8c6f1078a9e220076d5a08daf30077e8
CPU threads: 8; OS: Mac OS X 12.3.1; UI render: Skia/Metal; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded

This is still relatively expensive
                  sw::DocumentTimerManager::DoIdleJobs(Timer*)
                   SwViewShell::LayoutIdle()
                    SwLayIdle::SwLayIdle(SwRootFrame*, SwViewShellImp*)
                     SwViewShell::ImplUnlockPaint(bool)
                      VirtualDevice::ImplSetOutputSizePixel(Size const&, bool, unsigned char*)
                       VirtualDevice::InnerImplSetOutputSizePixel(Size const&, bool, unsigned char*)
                        AquaSalVirtualDevice::SetSize(long, long)
                         CGLayerCreateWithContext
                          CGContextDelegateCreateForContext
                           ripc_GetLayer
                            RIPLayerCreate
                             _malloc_zone_calloc
                            ripc_Initialize
                            pthread_mutex_init
Comment 6 Telesto 2022-12-26 12:41:12 UTC
Incomplete stack
                  sw::DocumentTimerManager::DoIdleJobs(Timer*)
                   SwViewShell::LayoutIdle()
                    SwLayIdle::SwLayIdle(SwRootFrame*, SwViewShellImp*)
                     SwViewShell::ImplUnlockPaint(bool)
                      VirtualDevice::ImplSetOutputSizePixel(Size const&, bool, unsigned char*)
                       VirtualDevice::InnerImplSetOutputSizePixel(Size const&, bool, unsigned char*)
                        AquaSalVirtualDevice::SetSize(long, long)
                         CGLayerCreateWithContext
                          CGContextDelegateCreateForContext
                           ripc_GetLayer
                            RIPLayerCreate
                             _malloc_zone_calloc
                              szone_malloc_should_clear
                               large_malloc
                                _platform_bzero$VARIANT$Haswell


See also
https://www.pybloggers.com/2016/12/debugging-your-operating-system-a-lesson-in-memory-allocation/

Starting from
The key note here is that we can clearly see that we’re spending the bulk of our time in _platform_bzero$VARIANT$Haswell. This method is used to zero buffers. This means that macOS is zeroing out the buffers. Why?
Comment 7 Telesto 2023-01-03 09:09:57 UTC
@Patrick
Xcode instruments shows that cpu time being spend in _platform_bzero$VARIANT$Haswell in a regular fashion while typing. The link in comment 6 suggests this not being optimal. The question: is this worth investigating or should the bug be closed as NOTABUG or WONTFIX
Comment 8 QA Administrators 2026-07-06 03:13:14 UTC
Dear Telesto,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug