关于AbstractWire.startUse/endUse中Throwable创建是否可设为可选的问询
Great catch on this performance hotspot—you’re absolutely right about the Throwable instances in AbstractWire.startUse() and endUse() being for tracking purposes. Here’s what you need to know:
Why Those Throwables Exist
The Throwable objects are created to capture stack traces that help debug thread-safety violations with Wire instances. Since Chronicle Wire is designed to be used by a single thread at a time, these stack traces let you identify cases where multiple threads accidentally access the same Wire (by showing where startUse() was called from when a conflict occurs).
Can You Make This Optional?
Yes! The Chronicle Network/Wire libraries already include a configuration to disable this tracking for production scenarios where you’ve verified single-threaded usage (like your case relying on thread references).
To disable the Throwable creation, you have two main options:
- System Property: Set the following JVM argument when starting your application:
-Dnet.openhft.chronicle.wire.disable-use-tracking=true - Programmatic Configuration: If you prefer setting it in code, you can toggle the flag directly early in your application startup:
System.setProperty("net.openhft.chronicle.wire.disable-use-tracking", "true");
Important Notes
- Safety: Since you’re already guaranteeing single-threaded access via thread references, disabling this tracking is completely safe—you won’t lose any necessary functionality for your use case.
- Debug vs Production: Keep this tracking enabled during development/testing if you want to catch accidental multi-threaded access issues. Only disable it in production to reduce GC overhead from the short-lived
Throwableobjects.
内容的提问来源于stack exchange,提问作者user2956246

