Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9307eb5
Feat: add FastAtomicIntArray
LinShunKang Feb 15, 2024
bd3774b
Perf: improve FastAtomicIntArray throughput
LinShunKang Feb 16, 2024
d35b287
Feat: improve the code logic of FastAtomicIntArray
LinShunKang Mar 17, 2024
2485459
Refactor: Correct the method name
LinShunKang Apr 29, 2024
c46402f
Feat: introduce FastAtomicIntArrayV1 and FastAtomicIntArrayV2
LinShunKang Apr 29, 2024
37c5fc3
Chore: upgrade minimal supported jdk version to 8
LinShunKang May 19, 2024
f4374c5
Perf: improve all atomic int array throughput
LinShunKang May 19, 2024
dbe73cb
Refactor: introduce AtomicIntArray Interface; remove FastAtomicIntArr…
LinShunKang Jun 16, 2024
32ac683
Merge branch 'master' into feature/4.0
LinShunKang Nov 16, 2025
f93a9d8
Feat: Remove RoughRecorder
LinShunKang Jul 13, 2024
f353b5c
Refactor: clean code
LinShunKang Jul 14, 2024
f4b403d
Refactor: clean code
LinShunKang Jul 14, 2024
82f4aa7
Chore: Upgrade project version to 4.0.0-SNAPSHOT
LinShunKang Nov 16, 2025
54b1a55
Feat: Use long[] as the underlying data structure for AtomicIntHashCo…
LinShunKang Apr 27, 2026
d46ad2c
Merge branch 'develop' into feature/AtomicIntHashCounter
LinShunKang Apr 29, 2026
ccfd0a6
Test: Update AtomicIntHashCounterBench result
LinShunKang Apr 29, 2026
a7b9639
Merge branch 'feature/AtomicIntHashCounter' into feature/4.0
LinShunKang May 1, 2026
cef5ed8
Refactor: Clean codes
LinShunKang May 2, 2026
28d5b19
Refactor: Clean codes
LinShunKang May 2, 2026
ac77e9d
Perf: Simple optimize AtomicIntHashCounter
LinShunKang May 3, 2026
150850a
Feat: Refine the code logic for AtomicIntHashCounter
LinShunKang May 5, 2026
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
6 changes: 3 additions & 3 deletions MyPerf4J-ASM/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MyPerf4J</artifactId>
<groupId>MyPerf4J</groupId>
<version>3.6.0</version>
<version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,8 +15,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static ASMBootstrap getInstance() {
public AbstractRecorderMaintainer doInitRecorderMaintainer() {
final RecorderConfig recorderConf = ProfilingConfig.recorderConfig();
final ASMRecorderMaintainer maintainer = ASMRecorderMaintainer.getInstance();
if (maintainer.initial(methodMetricsExporter, recorderConf.accurateMode(), recorderConf.backupCount())) {
if (maintainer.initial(methodMetricsExporter, recorderConf.backupCount())) {
return maintainer;
}
return null;
Expand Down
9 changes: 2 additions & 7 deletions MyPerf4J-Base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
<parent>
<artifactId>MyPerf4J</artifactId>
<groupId>MyPerf4J</groupId>
<version>3.6.0</version>
<version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MyPerf4J-Base</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<artifactId>MyPerf4J-Base</artifactId>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ public String toString() {
}

public static MetricsConfig loadMetricsConfig() {
MetricsConfig config = new MetricsConfig();

String exporter = getExporter();
final MetricsConfig config = new MetricsConfig();
final String exporter = getExporter();
config.metricsExporter(exporter);

config.methodMetricsFile(getMetricsFile(LOG_METHOD, exporter));
config.classMetricsFile(getMetricsFile(LOG_CLASS_LOADING, exporter));
config.gcMetricsFile(getMetricsFile(LOG_GC, exporter));
Expand All @@ -220,13 +218,10 @@ public static MetricsConfig loadMetricsConfig() {
config.threadMetricsFile(getMetricsFile(LOG_THREAD, exporter));
config.compilationMetricsFile(getMetricsFile(LOG_COMPILATION, exporter));
config.fileDescMetricsFile(getMetricsFile(LOG_FILE_DESC, exporter));

config.logRollingTimeUnit(getStr(LOG_ROLLING_TIME_UNIT, LOG_ROLLING_DAILY));
config.logReserveCount(getInt(LOG_RESERVE_COUNT, 7));

config.methodMilliTimeSlice(getLong(TIME_SLICE_METHOD, DEFAULT_TIME_SLICE));
config.jvmMilliTimeSlice(getLong(TIME_SLICE_JVM, DEFAULT_TIME_SLICE));

config.showMethodParams(getBoolean(METHOD_SHOW_PARAMS, true));
config.classLevelMapping(getStr(CLASS_LEVEL_MAPPINGS));
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public static boolean isNotNeedInject(String innerClassName) {
if (innerClassName.indexOf('$') >= 0) {
return true;
}

return isMatch(innerClassName, excludePackagePrefix, excludePackageExp);
}

Expand All @@ -112,11 +111,9 @@ private static boolean isMatch(String innerClassName, Set<String> pkgPrefixSet,
}

public static void addExcludePackage(String pkg) {
if (StrUtils.isEmpty(pkg)) {
return;
if (StrUtils.isNotEmpty(pkg)) {
addPackages(pkg, excludePackagePrefix, excludePackageExp);
}

addPackages(pkg, excludePackagePrefix, excludePackageExp);
}

private static void addPackages(String packages, Set<String> pkgPrefixSet, Set<String> pkgExpSet) {
Expand All @@ -143,28 +140,16 @@ public static boolean isNeedInject(String innerClassName) {
if (innerClassName == null) {
return false;
}

return isMatch(innerClassName, includePackagePrefix, includePackageExp);
}

public static void addIncludePackage(String pkg) {
if (StrUtils.isEmpty(pkg)) {
return;
if (StrUtils.isNotEmpty(pkg)) {
addPackages(pkg, includePackagePrefix, includePackageExp);
}

addPackages(pkg, includePackagePrefix, includePackageExp);
}

public static Set<String> getExcludePackagePrefix() {
return new HashSet<>(excludePackagePrefix);
}

public static Set<String> getIncludePackagePrefix() {
return new HashSet<>(includePackagePrefix);
}

/**
* @param methodName
* @return : true->需要修改字节码 false->不需要修改字节码
*/
public static boolean isNotNeedInjectMethod(String methodName) {
Expand All @@ -175,30 +160,23 @@ public static boolean isNotNeedInjectMethod(String methodName) {
if (isSpecialMethod(methodName)) {
return true;
}

return excludeMethods.contains(methodName);
}

private static boolean isSpecialMethod(String methodName) {
int symbolIndex = methodName.indexOf('$');
final int symbolIndex = methodName.indexOf('$');
if (symbolIndex < 0) {
return false;
}

int leftParenIndex = methodName.indexOf('(');
final int leftParenIndex = methodName.indexOf('(');
return leftParenIndex < 0 || symbolIndex < leftParenIndex;
}

public static void addExcludeMethods(String method) {
if (method == null) {
return;
if (method != null) {
excludeMethods.add(method.trim());
}

excludeMethods.add(method.trim());
}

public static Set<String> getExcludeMethods() {
return new HashSet<>(excludeMethods);
}

public static void addExcludeClassLoader(String classLoader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
import java.util.Map;

import static cn.myperf4j.base.config.MyProperties.getInt;
import static cn.myperf4j.base.config.MyProperties.getStr;
import static cn.myperf4j.base.constant.PropertyKeys.Recorder.BACKUP_COUNT;
import static cn.myperf4j.base.constant.PropertyKeys.Recorder.MODE;
import static cn.myperf4j.base.constant.PropertyKeys.Recorder.SIZE_TIMING_ARR;
import static cn.myperf4j.base.constant.PropertyKeys.Recorder.SIZE_TIMING_MAP;
import static cn.myperf4j.base.constant.PropertyValues.Recorder.MODE_ACCURATE;

/**
* Created by LinShunkang on 2020/05/24
*/
public class RecorderConfig {

private String mode;

private int backupCount;

private int timingArrSize;
Expand All @@ -29,18 +24,6 @@ public class RecorderConfig {

private final Map<String, ProfilingParams> profilingParamsMap = MapUtils.createHashMap(1024);

public String mode() {
return mode;
}

public void mode(String mode) {
this.mode = mode;
}

public boolean accurateMode() {
return MODE_ACCURATE.equalsIgnoreCase(mode);
}

public int backupCount() {
return backupCount;
}
Expand Down Expand Up @@ -74,27 +57,22 @@ public void addProfilingParam(String methodName, int timeThreshold, int outThres
}

public ProfilingParams getProfilingParam(String methodName) {
ProfilingParams params = profilingParamsMap.get(methodName);
if (params != null) {
return params;
}
return commonProfilingParams;
return profilingParamsMap.getOrDefault(methodName, commonProfilingParams);
}

@Override
public String toString() {
return "RecorderConfig{" +
"mode='" + mode + '\'' +
", backupCount=" + backupCount +
"backupCount=" + backupCount +
", timingArrSize=" + timingArrSize +
", timingMapSize=" + timingMapSize +
", commonProfilingParams=" + commonProfilingParams +
", profilingParamsMap=" + profilingParamsMap +
'}';
}

public static RecorderConfig loadRecorderConfig() {
final RecorderConfig config = new RecorderConfig();
config.mode(getStr(MODE, MODE_ACCURATE));
config.backupCount(getInt(BACKUP_COUNT, 1));
config.timingArrSize(getInt(SIZE_TIMING_ARR, 1024));
config.timingMapSize(getInt(SIZE_TIMING_MAP, 32));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ interface Recorder {

ConfigKey BACKUP_COUNT = ConfigKey.of("recorders.backup_count", "BackupRecordersCount");

ConfigKey MODE = ConfigKey.of("recorder.mode", "RecorderMode");

ConfigKey SIZE_TIMING_ARR = ConfigKey.of("recorder.size.timing_arr", "ProfilingTimeThreshold");

ConfigKey SIZE_TIMING_MAP = ConfigKey.of("recorder.size.timing_map", "ProfilingOutThresholdCount");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ interface Metrics {

interface Recorder {

String MODE_ACCURATE = "ACCURATE";

String MODE_ROUGH = "ROUGH";

int MIN_BACKUP_RECORDERS_COUNT = 1;

int MAX_BACKUP_RECORDERS_COUNT = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public HttpHeaders(Map<String, List<String>> headers) {
}

public String get(String name) {
List<String> values = headers.get(name);
final List<String> values = headers.get(name);
if (values == null || values.isEmpty()) {
return null;
}
Expand All @@ -47,12 +47,7 @@ public void set(String name, String value) {
}

public void add(String name, String value) {
List<String> values = headers.get(name);
if (values == null) {
values = new ArrayList<>(1);
headers.put(name, values);
}
values.add(value);
headers.computeIfAbsent(name, k -> new ArrayList<>(1)).add(value);
}

public List<String> names() {
Expand All @@ -64,7 +59,7 @@ public Map<String, List<String>> headers() {
}

public static HttpHeaders defaultHeaders() {
HttpHeaders headers = new HttpHeaders(6);
final HttpHeaders headers = new HttpHeaders(6);
headers.set("User-Agent", "MyPerf4J");
headers.set("Connection", "Keep-Alive");
headers.set("Charset", UTF_8.name());
Expand Down
24 changes: 7 additions & 17 deletions MyPerf4J-Base/src/main/java/cn/myperf4j/base/http/HttpRequest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package cn.myperf4j.base.http;

import cn.myperf4j.base.util.StrUtils;
import cn.myperf4j.base.util.collections.ArrayUtils;
import cn.myperf4j.base.util.collections.MapUtils;
import cn.myperf4j.base.util.StrUtils;

import java.util.List;
import java.util.Map;

import static cn.myperf4j.base.http.HttpMethod.GET;
import static cn.myperf4j.base.http.HttpMethod.HEAD;
import static cn.myperf4j.base.http.HttpMethod.POST;
import static cn.myperf4j.base.util.StrUtils.isNotEmpty;
import static java.nio.charset.StandardCharsets.UTF_8;

/**
Expand Down Expand Up @@ -75,20 +76,17 @@ public String getUrl() {
}

public String getFullUrl() {
if (StrUtils.isNotEmpty(fullUrl)) {
return fullUrl;
}
return fullUrl = createFullUrl();
return isNotEmpty(fullUrl) ? fullUrl : (fullUrl = createFullUrl());
}

private String createFullUrl() {
StringBuilder sb = SB_TL.get();
final StringBuilder sb = SB_TL.get();
try {
if (!url.startsWith("http://") && !url.startsWith("https://")) {
sb.append("http://");
}
sb.append(url);

sb.append(url);
if (MapUtils.isEmpty(params)) {
return sb.toString();
}
Expand All @@ -99,12 +97,7 @@ private String createFullUrl() {
sb.append('&');
}

for (Map.Entry<String, List<String>> param : params.entrySet()) {
final List<String> values = param.getValue();
for (int i = 0; i < values.size(); i++) {
sb.append(param.getKey()).append('=').append(values.get(i)).append('&');
}
}
params.forEach((k, vs) -> vs.forEach(v -> sb.append(k).append('=').append(v).append('&')));
return sb.substring(0, sb.length() - 1);
} finally {
sb.setLength(0);
Expand All @@ -113,10 +106,7 @@ private String createFullUrl() {

public String getParam(String key) {
final List<String> values = params.get(key);
if (values == null) {
return null;
}
return values.get(0);
return values != null ? values.get(0) : null;
}

public Boolean getBoolParam(String key) {
Expand Down
Loading