I regularly profile my team's high-performance Java program as inefficient functions can cause major slowdowns. To do so, I keep a port open for attaching Java VisualVM using the following Java machine arguments:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9011 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost
It struck me today: does profiling a Java program -- or simply keeping a port open for the sake of profiling -- introduce further speed reductions? If so, are some methods of profiling more costly than others? What kind of speed reduction or overhead -- e.g., 1% of runtime, 10% of runtime -- is normal to expect?
While my question is intended for the wider Java audience, I'll note that our program a is memory-light but CPU-intensive simulation: specifically, there are an enormous number of small but computationally expensive function calls being perpetually made. Perhaps optimization is expensive in our case given the sheer number of function calls, but less so for others?