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

Optimize execution of callbacks #1276

Merged
merged 1 commit into from
Jun 17, 2021
Merged

Conversation

fractalwrench
Copy link
Contributor

Goal

Bugsnag supplies the ability to set callbacks for when breadcrumbs are added, and when an error or session are captured. Breadcrumbs/errors in particular can be captured many times per second.

By default no callbacks are set. This changeset optimizes the default behaviour by performing an isEmpty() check before running the callbacks, which avoids construction of an iterator each time. For the addition of ~1000 breadcrumbs this saves ~3ms in the default case and has negligible impact when callbacks are set.

Testing

Verified by profiling the changes in an example app with no callbacks set and observing runOnBreadcrumbTasks():

baseline-no-cb

changes-no-cb

@fractalwrench fractalwrench force-pushed the PLAT-6752/callback-optimization branch from a33e068 to 80dbe60 Compare June 17, 2021 11:26
@fractalwrench fractalwrench marked this pull request as ready for review June 17, 2021 11:35
Copy link
Contributor

@lemnik lemnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fractalwrench fractalwrench force-pushed the PLAT-6752/callback-optimization branch from 80dbe60 to 2319487 Compare June 17, 2021 13:57
@fractalwrench fractalwrench merged commit e4cf4bc into next Jun 17, 2021
@fractalwrench fractalwrench deleted the PLAT-6752/callback-optimization branch June 17, 2021 14:32
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.

2 participants