Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

### Performance

- Read the clock once per performance collection round instead of once per in-flight transaction ([#5934](https://github.com/getsentry/sentry-java/pull/5934))
- Reduce allocations while collecting cpu usage during transactions by reading the process cpu time via `Process.getElapsedCpuTime()` instead of parsing `/proc/self/stat` (33.6kB to 16 bytes per sample on a Pixel 3) ([#5926](https://github.com/getsentry/sentry-java/pull/5926))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void run() {
// Add the enriched tempData to all transactions/profiles/objects that collect data.
// Then Check if that object timed out.
for (CompositeData data : compositeDataMap.values()) {
if (data.addDataAndCheckTimeout(tempData)) {
if (data.addDataAndCheckTimeout(tempData, tempData.getNanoTimestamp())) {
// timed out
if (data.transaction != null) {
timedOutTransactions.add(data.transaction);
Expand Down Expand Up @@ -224,16 +224,19 @@ private CompositeData(final @Nullable ITransaction transaction) {
* Adds the data to the internal list of PerformanceCollectionData. Then it checks if data
* collection timed out (for transactions only).
*
* @param nowNanos the timestamp of the current collection, passed in so a single clock reading
* is shared by every transaction in this collection round.
* @return true if data collection timed out (for transactions only).
*/
boolean addDataAndCheckTimeout(final @NotNull PerformanceCollectionData data) {
boolean addDataAndCheckTimeout(
final @NotNull PerformanceCollectionData data, final long nowNanos) {
// stop() hands dataList out while this timer thread may still be writing to it, so consumers
// synchronize on the list while iterating. We must hold the same monitor here.
synchronized (dataList) {
dataList.add(data);
}
return transaction != null
&& options.getDateProvider().now().nanoTimestamp()
&& nowNanos
> startTimestamp
+ TimeUnit.MILLISECONDS.toNanos(TRANSACTION_COLLECTION_TIMEOUT_MILLIS);
}
Expand Down
Loading