-
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
gcp-observability: Optimize GcpObservabilityTest.enableObservability execution time #11783
Conversation
….enableObservability test case.
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.
If this is the problem then should we do same in line 233 in original code or 236 after your commit as well? It has the same try-with-resource block usage and I don't see anywhere in grpc-java anything similar like this.
As I have observed, enabling observability requires initializing certain things and classes, which makes the task within the try-with-resources block take longer. However, when observability is disabled, I did not observe many initializations in the test cases at lines 233 and 236, so I refactored the code to use a traditional try-catch block instead. |
You just don't close? No, we need to clean up and we want to test cleanup. Without close() we will leak resources and probably threads, and we don't want those running during other tests. |
I’m working on this and plan to implement a close() method with a configurable sleep time. After the test finishes, the close() method will be called with a shorter sleep duration to speed up the cleanup process. |
That sounds fine; just make the new method package-private. |
….enableObservability test case.
As per the suggestions above, I have pushed the latest changes, which include the addition of a new close method with sleep time. After executing the test case, I found that the execution time is now under 5 seconds. Could you please review the changes. |
gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java
Outdated
Show resolved
Hide resolved
….enableObservability test case - fixed review comments.
….enableObservability test case - fixed review comments.
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.
Changes LGTM and Lets wait for Review from @ejona86 @shivaspeaks
gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java
Outdated
Show resolved
Hide resolved
…bleObservability test case.
I have resolved all comments as per above mentioned and Kindly look into it once. |
gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/GcpObservability.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java
Outdated
Show resolved
Hide resolved
synchronized (GcpObservability.class) { | ||
if (instance == null) { | ||
throw new IllegalStateException("GcpObservability already closed!"); | ||
} | ||
sink.close(); | ||
if (config.isEnableCloudMonitoring() || config.isEnableCloudTracing()) { | ||
try { | ||
// Sleeping before shutdown to ensure all metrics and traces are flushed |
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.
Restore this comment. If you don't think it makes sense here any more (I'm assuming that's why you deleted it), then at least move it to close()
just before the closeWithSleepTime()
call.
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.
Resolved and restored the comment.
@@ -49,6 +49,7 @@ | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.junit.runners.JUnit4; | |||
import java.util.concurrent.TimeUnit; |
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.
Please put it in Lexicographical order.
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.
Resolved
@shivaspeaks, I have resolved all the comments and all checks have passed. Kindly look into it once. |
gcp-obsrevability : Fixed the slowness issue for GcpObservabilityTest.enableObservability test case.
Fixes #10146.
Snippet before fix as execuation time taking 1m 21sec
Snippet after fix as execuation time taking below 1sec 44msec.