-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
There should be a way to disable OpenCensus stats and tracing #5510
Comments
There is no public API to disable it because there was no strong demand from users. However, there is a hack: enabling retry will disable census as a side effect for the current version of grpc library (Note: This behavior is subject to change in future releases). |
Thanks @dapengzhang0
Strong demand for the associated functionality or strong demand to disable these flags? If the former wouldn't that be all the more reason for them to be off by default? and if the latter I expect that's because most aren't aware of them or the fact a free performance boost is available by switching them off :)
This only applies to client-side, there's no way to do the equivalent on the server side. Interestingly if you also don't want retry then |
As we revisit the decision to include the OpenCensus into
Option 1 allows current stats/tracing-dependent users to migrate without any code change. Option 2 is cleaner as it gives the user the maximum control, while it requires code changes to migrate. I personally prefer Option 2 but I am not sure whether the churn brought to users is acceptable. @ejona86 may want to chime in. |
Thanks @zhangkun83. My vote would be for both! i.e. have the default settings determined by presence of the grpc-census classes, but also provide a means of explicit/finer-grained control. Wouldn't that give the best of both worlds? i.e. existing census users could upgrade without requiring any code/config changes while those who don't use it would benefit from it being turned off automatically. Maybe a third option to consider at some point (also not mutually exclusive) is investigating the reason for the overhead; maybe there's some low-hanging optimizations which could cut that down. |
@zhangkun83 I think Option 1 might require current stats/tracing-dependent users to migrate with dependency change. |
I agree with @dapengzhang0 - option 1 is a breaking change for users using stats/tracing. So option 2 is better - except have the utility class in grpc-core instead of grpc-census (if possible). |
The `ThreadlessExecutor` currently used for blocking calls uses `LinkedBlockingQueue` which is relatively heavy both in terms of allocations and synchronization overhead (e.g. when compared to `ConcurrentLinkedQueue`). It accounts for ~10% of allocations and ~5% of allocated bytes per-call in the `TransportBenchmark` when using in-process transport with [stats and tracing disabled](#5510). Changing to use a `ConcurrentLinkedQueue` results in a ~5% speedup of that benchmark. Before: ``` Benchmark (direct) (transport) Mode Cnt Score Error Units TransportBenchmark.unaryCall1024 true INPROCESS avgt 60 1877.339 ± 46.309 ns/op TransportBenchmark.unaryCall1024 false INPROCESS avgt 60 12680.525 ± 208.684 ns/op ``` After: ``` Benchmark (direct) (transport) Mode Cnt Score Error Units TransportBenchmark.unaryCall1024 true INPROCESS avgt 60 1779.188 ± 36.769 ns/op TransportBenchmark.unaryCall1024 false INPROCESS avgt 60 12532.470 ± 238.271 ns/op ```
@dapengzhang0 @sanjaypujare I don't follow why 1 can't be done without breaking existing users? static boolean classFound(String name) {
try {
Class.forName(name, /* init = */ false, StatsComponent.class.getClassLoader());
return true;
} catch (ClassNotFoundException e) { }
return false;
}
boolean enableStats = classFound("io.opencensus.impl.stats.StatsComponentImpl")
|| classFound("io.opencensus.impllite.stats.StatsComponentImplLite");
boolean enableTracing = classFound("io.opencensus.impl.trace.TraceComponentImpl")
|| classFound("io.opencensus.impllite.trace.TraceComponentImplLite"); |
@njhill Option 1 will be depending on a new artifact |
@njhill So people who do want to use stats/tracing will need to add the new dependency grpc-census in their build to maintain existing functionality. Without that change it breaks, isn't that right? |
@dapengzhang0 @sanjaypujare ok sorry I think I didn't properly digest @zhangkun83's comment which is specifically talking about how to proceed with splitting the opencensus-specific logic into a separate module. I was actually more interested in something which could hopefully be a simpler and non-breaking first step - to control whether the interceptors are enabled based on presence of the opencensus impl classes themselves. |
I've opened #5520 for consideration. |
Currently, out-of-the-box client and server config includes a very expensive "no-op" in the form of the enabled-by-default opencensus tracing and stats interceptors. This is the case even if no implementation library is on the classpath, and disabling them is difficult/discouraged/impossible (without reflection) depending on the transport.
There's also significantly more garbage produced when enabled.
It would be great to enable these only when the impl library is detected, however:
Could these be changed to be disabled by default? I'm unsure why such settings are considered internal when they pertain to external functionality. There's not much danger of anyone "accidentally" leaving it disabled since it would be immediately apparent that the stats aren't working but the converse is of course true and I would assume most common.
The text was updated successfully, but these errors were encountered: