Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize getInbox usage and shared pointer handling in loops #3150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dudantas
Copy link
Contributor

Description

This addresses performance issues by optimizing the use of shared pointers and removing redundant calls. Specifically, the getInbox call was removed from extensive loops to prevent unnecessary reference count increments, which were causing CPU overhead. Additionally, shared pointers used in recursive or iteration-heavy functions, such as the ContainerIterator, were changed to const& where applicable, reducing the impact of reference counting on performance.

Fixes this perf report: 23_11_20_18.txt

Behaviour

Actual

When iterating over container items or processing inbox elements in loops, excessive reference count updates for shared pointers caused significant CPU strain, leading to reduced performance under heavy load.

Expected

The changes reduce the number of reference count updates and improve performance, particularly in recursive contexts and large loops involving container operations.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested

The changes were tested by running performance benchmarks during typical server operations to ensure that the CPU usage was reduced in scenarios involving container iterations and recursive pointer accesses.

  • Test A: Benchmark with container iteration to measure CPU usage before and after the change.
  • Test B: Stress test with simulated load to verify the absence of performance degradation.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@dudantas dudantas changed the title perf: remove "inbox" from inside extensive loops perf: remove "getInbox" from inside extensive loops Nov 24, 2024
@dudantas dudantas changed the title perf: remove "getInbox" from inside extensive loops perf: optimize getInbox usage and shared pointer handling in loops Nov 24, 2024
Removed getInbox from extensive loops and optimized pointer usage by changing certain shared pointers to const&. These pointers were frequently accessed in recursive calls or iteration-heavy functions, such as the ContainerIterator, reducing unnecessary reference count increments and improving CPU performance.
@dudantas dudantas force-pushed the dudantas/perf-pointers-to-const-ref branch from bafe7eb to d22a5df Compare November 24, 2024 04:00
Copy link

sonarcloud bot commented Nov 24, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant