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

Don't copy FeatureFlags on the crashing thread #2005

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

lemnik
Copy link
Contributor

@lemnik lemnik commented Apr 5, 2024

Goal

Avoid making defensive copies of the feature flags on the notifying thread (unless they are altered in an OnErrorCallback).

Design

Replaced the LinkedHashMap with a Copy-On-Write data structure. To avoid multiple levels of locking, and the need for iterators this is a simple encapsulated array which is copied each time a change is required.

The new implementation is slower when adding & removing feature flags (since each addition or removal is now O(n) rather than O(1)), but since there are relatively few feature flags added per run (<1000) this should be a reasonable trade-off as now the feature flags do not need any synchronization or defensive copying when an error report is required.

Testing

Additional tests for the new implementation and existing tests still pass.

@lemnik lemnik requested review from kstenerud and YYChen01988 April 5, 2024 13:07
@lemnik lemnik force-pushed the PLAT-11866/copy-on-write-feature-flags branch from d003ab6 to 8943350 Compare April 5, 2024 13:09
@bugsnagbot
Copy link
Collaborator

Android notifier sizes

Format Size impact of Bugsnag (kB) Size impact of Bugsnag when Minified (kB)
APK 1843.62 1668.05
arm64_v8a 626.95 450.82
armeabi_v7a 561.42 385.29
x86 700.66 524.53
x86_64 671.99 495.86

Generated by 🚫 Danger

Copy link
Contributor

@YYChen01988 YYChen01988 left a comment

Choose a reason for hiding this comment

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

LGTM

@lemnik lemnik merged commit cabac65 into next Apr 9, 2024
26 checks passed
@lemnik lemnik deleted the PLAT-11866/copy-on-write-feature-flags branch April 9, 2024 07:40
@YYChen01988 YYChen01988 mentioned this pull request Apr 15, 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.

4 participants