[PLAT-7804] Improve crash report writing performance with buffered output #1281
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
Improve the performance of writing crash reports, to reduce the likelihood of apps being terminated (by watchdog or user) before finishing.
Design
Use write buffers to reduce the number of calls to
write()
.malloc()
'd at run-time due to the constrained crash-time environment. Thoughts on the safety of this are welcome - perhaps static allocation should be used instead at the expense of thread safety (which is not something we support in the crash handler.)Changeset
BSG_KSFile.c
.BSG_KSCrashReport.c
to use buffered output.BSG_KSCrashState.m
to use buffered output.Testing
Tested by updating unit tests
BSG_KSCrashReportTests
andKSCrashState_Tests
.Also verified by manually inspecting crash report files and running full E2E suite on CI. Bugs in file writing would manifest as unreported crashes.
The performance unit test case shows improvements of 40-60% depending on the device.
Profiling shows that around 95% of
bsg_kscrashreport_writeStandardReport()
's time is now spent inbsg_symbolicate()
.