Skip to content

Commit

Permalink
Add DynamicProxyNormalization
Browse files Browse the repository at this point in the history
  • Loading branch information
dagguh committed Jul 1, 2024
1 parent 67cf310 commit b8ba104
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Dropping a requirement of a major version of a dependency is a new contract.
- Add `MutableJvmSymbol`, `JfrFilter.Builder.symbolModifier` and `MultiJfrFilter.Builder.symbolModifier`.
They allow for mutating JVM symbols in JFR files, e.g. to normalize dynamic proxy names or lambda names.
This way, the same JVM code can be profiled multiple times and resulting JFRs can be merged or diffed.
- Add `DynamicProxyNormalization`.

## [4.4.0] - 2024-01-18
[4.4.0]: https://github.com/atlassian/report/compare/release-4.3.0...release-4.4.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.atlassian.performance.tools.report.api.jfr

import java.nio.ByteBuffer
import java.util.function.Consumer

class DynamicProxyNormalization : Consumer<MutableJvmSymbol> {

private val proxyClassName = Regex("\\\$Proxy[0-9]")
private val proxyPackageName = Regex("proxy[0-9]")

override fun accept(symbol: MutableJvmSymbol) {
val symbolString = symbol.toString()
if (symbolString.contains(proxyClassName) || symbolString.contains(proxyPackageName)) {
val newSymbol = "PROXY".padEnd(symbol.payload.size, '_')
ByteBuffer.wrap(symbol.payload).put(newSymbol.toByteArray())
}
}
}


Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.atlassian.performance.tools.report.jfr

import com.atlassian.performance.tools.report.api.jfr.DynamicProxyNormalization
import com.atlassian.performance.tools.report.api.jfr.JfrFilter
import com.atlassian.performance.tools.report.api.jfr.MutableJvmSymbol
import com.atlassian.performance.tools.report.api.result.CompressedResult
Expand Down Expand Up @@ -148,7 +149,7 @@ class JfrFilterTest {
assertThat(before.uniqueSymbols).containsAll(proxies)
// when
val output = JfrFilter.Builder()
.symbolModifier(Consumer(this::normalizeDynamicProxy))
.symbolModifier(DynamicProxyNormalization())
.build()
.filter(input)

Expand Down

0 comments on commit b8ba104

Please sign in to comment.