It takes around 6-8 seconds to crate environment variable. Even if we remove thresholdLoggingTracerConfig or use just below code to create default environment, it remains same.
environment = ClusterEnvironment.builder()
Is any better way to optimize this creation and also can you please help me to understand why it takes this much time to create environment.
ClusterEnvironment creation should be instant, as should Cluster.connect: neither is doing any real synchronous IO work. We’ve not seen any such issues in our testing or had any user reports on it either.
I’d suggest attaching a profiler and seeing where the sticking point is.
If you can send a kill -3 while it is executing will give a thread dump and be able to see a little bit what it is doing.
environment = ClusterEnvironment.builder()
There is really nothing to that. All that needs to happen is that the classes get loaded. And 6-8 seconds is really, really long for that. I get 152 ms.
long t0=System.currentTimeMillis();
ClusterEnvironment.Builder env = ClusterEnvironment.builder();
System.err.print("et: "+(System.currentTimeMillis()-t0));
et: 152
In your original sample there are tracerConfig.getLong() and couchbaseConfig.getLong() calls which are not couchbase. You might want to investigate what they do.
SLF4J is a logging facade that routes logging requests to a specific logger implementation (like logback, logj42, etc.). Which SLF4J binding are you using?
I Agree with this but our logger is intialized much before this method and when we evaluate logs, exactly those 2 logs before and after is taking time… rest all logs are ok… there are 15-20 logs before creation of environment. All are ok and on time.
I am yet to run profiler.