Skip to content

perfomance(blocks_button): remove recursive and redudant paint call in paintevent#246

Merged
HugoCLSC merged 2 commits into
devfrom
perf/fix-recursive-paint
Jun 26, 2026
Merged

perfomance(blocks_button): remove recursive and redudant paint call in paintevent#246
HugoCLSC merged 2 commits into
devfrom
perf/fix-recursive-paint

Conversation

@gmmcosta15

Copy link
Copy Markdown
Collaborator

Description

Select the type:

  • Feature
  • Bug fix
  • Code refactor
  • Documentation

This change introduces a major fix in the paintEvent() implementation of blocks_button.

Previously, paintEvent() called setStyle(), which internally triggered an update(). This resulted in a recursive repaint cycle where paintEvent() indirectly caused additional paintEvent() calls through unnecessary update() requests.

By removing the setStyle() call from paintEvent(), these redundant updates are eliminated, significantly improving performance on Raspberry Pi devices.

Performance improvements observed:

  • Idle CPU usage reduced from approximately 40% to 2%.
  • GIL usage reduced from approximately 73% to below 10%.
  • Active Thread usage reduced from approximately 90% to 7%.

Motivation

The application was consistently consuming nearly an entire CPU core while idle.

After a careful investigation, the root cause was identified as the recursive repaint/update behavior in blocks_button. Removing the unnecessary setStyle() call from paintEvent() eliminates the excessive repaint requests, resulting in a drastic reduction in CPU usage and significantly improved idle performance.

@gmmcosta15 gmmcosta15 added enhancement New feature or request. MajorUpdate An update that introduces major changes overall codeto the labels Jun 25, 2026
@gmmcosta15 gmmcosta15 self-assigned this Jun 25, 2026
@gmmcosta15 gmmcosta15 requested a review from HugoCLSC June 25, 2026 11:04
@HugoCLSC HugoCLSC merged commit 84823a5 into dev Jun 26, 2026
6 of 7 checks passed
@HugoCLSC HugoCLSC deleted the perf/fix-recursive-paint branch June 26, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request. MajorUpdate An update that introduces major changes overall codeto the

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants