-
Notifications
You must be signed in to change notification settings - Fork 864
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
Tracking getResourceAsStream() performance #5369
Comments
One might be inclined to simply say "Well easy, the Android app should just initialize the SDK on a background thread and not the main/ui thread.". But it's not that easy. Unfortunately, in order to track startup time and follow early application lifecycle events, the SDK must first be initialized. Without that, a mobile telemetry solution would essentially need to create its own flavor of instrumentation that could be used and deferred/buffered until the otel SDK initialization is completed. This parallel/shadow/deferred telemetry implementation would result in significant increase in complexity and weakens what is otherwise a straightforward use of the otel sdk. As far as I can tell so far, there's really nothing else that's thread-blocking, nor is there other IO being done in SDK creation. If we discover some, we could address those on a case-by-case basis. |
Ok I think I understand better - thanks for that explanation! This sounds similar to some of the valid use cases for I'm not very familiar with android environments - are there other types of things we need to be aware of / avoid during SDK initialization besides reading from resources? Is the pattern in #5365 something that |
I haven't thought about it before but yes, that is something we'll need to do at least for the instrumentations that are commonly used on Android (probably these that use |
Yeah, the primary concern is doing any blocking I/O, like disk and network. The I wonder if we'll hit DNS lookups again. There are a few things in the android sdk that we were already able to defer or otherwise make lazy, but I can't remember details offhand. |
Do you have ideas of when DNS lookups might occur during initialization? |
I don't. I don't mind chatting through these things so that there's a record in case we eventually want to circle back....but I hope we can prevent this issue from becoming an android startup-delay omnibus instead of keeping the discussion narrowly focused on the thing we do know already causes a problem. |
@jack-berg asked in #5365 for this issue to be opened.
The basic idea is that
getResourceAsStream()
can have negative performance ramifications on some platforms, specifically Android.This can be detected when initializing the SDK on the main thread with strict mode enabled, as shown in this issue.
There is some detailed information about the performance of
getResourceAsStream()
and some of the causes in this article:https://blog.nimbledroid.com/2016/04/06/slow-ClassLoader.getResourceAsStream.html
To the extent that we can provide reasonable alternatives or remove usages of
getResourceAsStream()
, especially in SDK internals, this will help Android users. There is already a pretty well-establish precedent of not doing any heavy lifting in the service/application path and doing IO in the background, so this seems to fit in with that.The text was updated successfully, but these errors were encountered: