[PLAT-8410] Add device.time
to OOM and Thermal Kill events
#1355
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
Provide a timestamp for OOM and Thermal Kill events so that the dashboard renders breadcrumbs with sensible relative timestamps.
Changeset
Adds a
timestamp
field toBSGRunContext
which is updated from a timer and in response to certain events (so thatdevice.time >= breadcrumbs.last.timestamp
)Sets
device.time
for OOM and TK events based on the last run's context.Uses
CFAbsoluteTimeGetCurrent()
as the source of timing information, which provides a wall-clock time equivalent to[NSDate date].timeIntervalSinceReferenceDate
.Performance
CFAbsoluteTime()
is very fast on recent OS versions (~70 nanoseconds on iPhone 5s with iOS 12) where it does not need to call into the kernel.On iPad 3 running iOS 9 it takes ~1400 nanoseconds (1.4 µs) which while much slower is still reasonable for the frequency at which this code calls it. For comparison, a single character
write()
to stdout takes ~8 µs.Considered using
mach_approximate_time()
which is much faster (~45 nanoseconds on iPad 3) but since it would be difficult (perhaps impossible?) to convert to the required wall-clock time and only old devices / OSes would benefit, the extra complexity does not feel justified.Testing
Amends OOM barebone E2E scenario to verify presence of
device.time
.Manually verified outcome on dashboard using example app.