Skip to content

Commit bfe6f3a

Browse files
committed
Remove debug timing instrumentation from tracer
Strip AtomicLong accumulators, System.nanoTime() timing, and getTimingSummary() that were added for profiling. No functional change.
1 parent 01e2215 commit bfe6f3a

2 files changed

Lines changed: 0 additions & 41 deletions

File tree

codeflash-java-runtime/src/main/java/com/codeflash/tracer/TraceRecorder.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.util.concurrent.TimeUnit;
1313
import java.util.concurrent.TimeoutException;
1414
import java.util.concurrent.atomic.AtomicInteger;
15-
import java.util.concurrent.atomic.AtomicLong;
1615

1716
public final class TraceRecorder {
1817

@@ -24,8 +23,6 @@ public final class TraceRecorder {
2423
private final TraceWriter writer;
2524
private final ConcurrentHashMap<String, AtomicInteger> functionCounts = new ConcurrentHashMap<>();
2625
private final AtomicInteger droppedCaptures = new AtomicInteger(0);
27-
private final AtomicLong totalOnEntryNs = new AtomicLong(0);
28-
private final AtomicLong totalSerializationNs = new AtomicLong(0);
2926
private final int maxFunctionCount;
3027
private final ExecutorService serializerExecutor;
3128

@@ -71,8 +68,6 @@ public void onEntry(String className, String methodName, String descriptor,
7168

7269
private void onEntryImpl(String className, String methodName, String descriptor,
7370
int lineNumber, String sourceFile, Object[] args) {
74-
long entryStart = System.nanoTime();
75-
7671
String qualifiedName = className + "." + methodName + descriptor;
7772

7873
// Check per-method count limit
@@ -83,7 +78,6 @@ private void onEntryImpl(String className, String methodName, String descriptor,
8378

8479
// Serialize args — try inline fast path first, fall back to async with timeout
8580
byte[] argsBlob;
86-
long serStart = System.nanoTime();
8781
argsBlob = Serializer.serializeFast(args);
8882
if (argsBlob == null) {
8983
// Slow path: async serialization with timeout for complex/unknown types
@@ -104,15 +98,12 @@ private void onEntryImpl(String className, String methodName, String descriptor,
10498
return;
10599
}
106100
}
107-
totalSerializationNs.addAndGet(System.nanoTime() - serStart);
108101

109102
long timeNs = System.nanoTime();
110103
count.incrementAndGet();
111104

112105
writer.recordFunctionCall("call", methodName, className, sourceFile,
113106
lineNumber, descriptor, timeNs, argsBlob);
114-
115-
totalOnEntryNs.addAndGet(System.nanoTime() - entryStart);
116107
}
117108

118109
public void flush() {
@@ -139,16 +130,5 @@ public void flush() {
139130
System.err.println("[codeflash-tracer] Captured " + totalCaptures
140131
+ " invocations across " + functionCounts.size() + " methods"
141132
+ (dropped > 0 ? " (" + dropped + " dropped due to serialization timeout/failure)" : ""));
142-
143-
// Timing summary
144-
long onEntryMs = totalOnEntryNs.get() / 1_000_000;
145-
long serMs = totalSerializationNs.get() / 1_000_000;
146-
String writerSummary = writer.getTimingSummary();
147-
System.err.println("[codeflash-tracer] Timing: onEntry=" + onEntryMs + "ms"
148-
+ " (serialization=" + serMs + "ms)"
149-
+ (totalCaptures > 0
150-
? " avg=" + String.format("%.2f", (double) onEntryMs / totalCaptures) + "ms/capture"
151-
: "")
152-
+ " " + writerSummary);
153133
}
154134
}

codeflash-java-runtime/src/main/java/com/codeflash/tracer/TraceWriter.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import java.util.concurrent.ArrayBlockingQueue;
1515
import java.util.concurrent.TimeUnit;
1616
import java.util.concurrent.atomic.AtomicBoolean;
17-
import java.util.concurrent.atomic.AtomicInteger;
18-
import java.util.concurrent.atomic.AtomicLong;
1917

2018
public final class TraceWriter {
2119

@@ -28,10 +26,6 @@ public final class TraceWriter {
2826
private final BlockingQueue<WriteTask> writeQueue;
2927
private final Thread writerThread;
3028
private final AtomicBoolean running;
31-
private final AtomicLong totalWriteNs = new AtomicLong(0);
32-
private final AtomicInteger batchCount = new AtomicInteger(0);
33-
private final AtomicInteger taskCount = new AtomicInteger(0);
34-
private volatile long dumpToFileMs = 0;
3529

3630
private PreparedStatement insertFunctionCall;
3731
private PreparedStatement insertMetadata;
@@ -150,7 +144,6 @@ private void executeBatch(List<WriteTask> batch) {
150144
return;
151145
}
152146

153-
long writeStart = System.nanoTime();
154147
boolean hasFunctionCalls = false;
155148
try {
156149
for (WriteTask task : batch) {
@@ -176,9 +169,6 @@ private void executeBatch(List<WriteTask> batch) {
176169
System.err.println("[codeflash-tracer] Rollback failed: " + re.getMessage());
177170
}
178171
}
179-
totalWriteNs.addAndGet(System.nanoTime() - writeStart);
180-
batchCount.incrementAndGet();
181-
taskCount.addAndGet(batch.size());
182172
}
183173

184174
public void flush() {
@@ -192,15 +182,6 @@ public void flush() {
192182
}
193183
}
194184

195-
public String getTimingSummary() {
196-
long writeMs = totalWriteNs.get() / 1_000_000;
197-
int batches = batchCount.get();
198-
int tasks = taskCount.get();
199-
return "writes=" + writeMs + "ms (" + tasks + " tasks in " + batches + " batches"
200-
+ (batches > 0 ? ", avg=" + String.format("%.1f", (double) tasks / batches) + " tasks/batch" : "")
201-
+ ") dump=" + dumpToFileMs + "ms";
202-
}
203-
204185
public void close() {
205186
running.set(false);
206187
try {
@@ -218,7 +199,6 @@ public void close() {
218199
}
219200

220201
if (inMemory) {
221-
long dumpStart = System.nanoTime();
222202
try {
223203
connection.commit();
224204
connection.setAutoCommit(true);
@@ -228,7 +208,6 @@ public void close() {
228208
} catch (SQLException e) {
229209
System.err.println("[codeflash-tracer] Failed to write trace DB to disk: " + e.getMessage());
230210
}
231-
dumpToFileMs = (System.nanoTime() - dumpStart) / 1_000_000;
232211
}
233212

234213
try {

0 commit comments

Comments
 (0)