-
Notifications
You must be signed in to change notification settings - Fork 64
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
RUM-6039 Fix StrictMode warning regarding I/O disk operation on main thread #2284
RUM-6039 Fix StrictMode warning regarding I/O disk operation on main thread #2284
Conversation
71fd9a7
to
90aaa08
Compare
@@ -51,7 +52,7 @@ internal class NdkCrashReportsFeature( | |||
NDK_CRASH_REPORTS_FOLDER | |||
) | |||
try { | |||
allowThreadDiskReads { | |||
allowThreadDiskWrites { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why do we need to create the dirs on the main thread, maybe the owner of this code can give more info while reviewing this code. Tks !!.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are the original owner of this logic :) aa1ff53#diff-11c9203b7b745ca318ece104c990b0d0d70353ecee0d6be0ec15574c31a2844aR52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes and no, I didn't wrote that function allowThreadDiskRead
, I think @xgouchet did ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check line 54 and 56 ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm referencing the code to create directories, not to allow I/O. This code to call directories creation on the main thread was since the creation of NDK module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup I am getting to understand why, this is going inside the NDK but I don't see a reason why we should just not pass the path to the ndk and create the file inside when we actually write the first content. What do you think ? Not sure if it is a change to do it now or maybe just keep it as it is ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path is also used in DatadogNdkCrashHandler
, so we need to make sure that any change we do to this logic is compatible.
We maybe indeed can create it only when crash happens, the downside is that we will lose the time on the folder creation during the crash itself, when time is precious, but maybe the time penalty of such call is negligible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that's the reason why I am afraid as when the signal is handle you are in a different state it is not the same as in the JVM crash state. You have so little time to do something then the process is killed so you need to be very efficient there, I think for this main reason I prefer in this case to have that folder created already.
...-core/src/main/kotlin/com/datadog/android/core/internal/persistence/file/FileOrchestrator.kt
Outdated
Show resolved
Hide resolved
@@ -63,7 +63,7 @@ internal class ConsentAwareStorage( | |||
callerClass = ConsentAwareStorage::class.java.name, | |||
metric = TelemetryMetricType.MethodCalled, | |||
samplingRate = MethodCallSamplingRate.RARE.rate, | |||
operationName = "writeCurrentBatch[${orchestrator?.getRootDir()?.nameWithoutExtension}]" | |||
operationName = "writeCurrentBatch[${orchestrator?.getRooDirName()}]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: I'm not even sure what is the point of having directory name here. With what we currently have it will be essentially (value of operationName
):writeCurrentBatchrum-pending-v2
or writeCurrentBatchrum-v2
.
Assuming that tracking consent information is probably useless, we are interested mostly in the feature name, which is a part of MetricsDispatcher
already, so can be removed from here and be an additional attribute of all the events sent. But this performance metric is not using MetricsDispatcher
, but InternalLogger
, which is confusing.
It would be much more sense to have operation name = writeCurrentBatch
and feature name attached as an attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the thing I asked on the original thread in Slack but no - one answered so I said to go with this and discuss it here maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could just use feature name here....it will remove a lot of boiler code, what do you all think ? The only thing is that we will miss the folder type ? Granted/Pending. For that we can also pass the tracking consent in the operationName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid growing constructor much. Also what is the point of having tracking consent here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add enrich MetricsDispatcher
? Implementation already has everything needed: logger and feature name,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for more opinions here before getting into it but I think it is the right call instead of using the root dir name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only thing is to not affect the metric which is based on the operationName
in the dashboards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is our internal metric, so we can break it at any time.
3cf5c30
to
775c31b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2284 +/- ##
===========================================
- Coverage 70.03% 69.93% -0.10%
===========================================
Files 732 732
Lines 27228 27204 -24
Branches 4580 4571 -9
===========================================
- Hits 19069 19024 -45
- Misses 6883 6895 +12
- Partials 1276 1285 +9
|
775c31b
to
1947770
Compare
What does this PR do?
Fixes: #2229
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)