richardstartin commented on a change in pull request #8443:
URL: https://github.com/apache/pinot/pull/8443#discussion_r840059306
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/util/trace/TraceContext.java
##########
@@ -67,7 +68,7 @@ JsonNode toJson() {
final String _traceId;
final List<LogEntry> _logs = new ArrayList<>();
- int _numChildren = 0;
+ AtomicInteger _numChildren = new AtomicInteger(0);
Review comment:
It can be useful to save memory and indirections with
`Atomic*FieldUpdater`s, you can use one as follows:
```java
private static final AtomicIntegerFieldUpdater<Trace> UPDATER =
AtomicIntegerFieldUpdater.newUpdater(Trace.class, "_numChildren");
private volatile int _numChildren;
...
return _traceId + "_" + UPDATER.getAndIncrement(this);
```
At the very least, please make `_numChildren` final if it remains an
`AtomicInteger`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]