This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new d24b2a37 IGNITE-28409 Added cache store operations to the performance
report (#338)
d24b2a37 is described below
commit d24b2a37f541d4955197722dec50e126ef730a91
Author: Aleksandr Chesnokov <[email protected]>
AuthorDate: Wed Apr 1 17:48:52 2026 +0300
IGNITE-28409 Added cache store operations to the performance report (#338)
---
.../report/js/operationsTab.js | 131 +++++++++++++--------
.../PerformanceStatisticsReportSelfTest.java | 58 +++++++++
2 files changed, 138 insertions(+), 51 deletions(-)
diff --git a/modules/performance-statistics-ext/report/js/operationsTab.js
b/modules/performance-statistics-ext/report/js/operationsTab.js
index fc08d03d..1ea82927 100644
--- a/modules/performance-statistics-ext/report/js/operationsTab.js
+++ b/modules/performance-statistics-ext/report/js/operationsTab.js
@@ -22,6 +22,11 @@ const CACHE_OPERATIONS = ["CACHE_GET", "CACHE_PUT",
"CACHE_REMOVE", "CACHE_GET_A
const CACHE_OPERATIONS_READABLE = ["get", "put", "remove", "getAndPut",
"getAndRemove",
"getAll", "putAll", "removeAll", "invoke", "invokeAll", "putAllConflict",
"removeAllConflict", "lock"];
+const CACHE_STORE_OPERATIONS = ["CACHE_LOAD", "CACHE_LOAD_ALL",
"CACHE_LOAD_CACHE",
+ "CACHE_WRITE", "CACHE_WRITE_ALL", "CACHE_DELETE", "CACHE_DELETE_ALL"];
+
+const CACHE_STORE_OPERATIONS_READABLE = ["load", "loadAll", "loadCache",
"write", "writeAll", "delete", "deleteAll"];
+
const CACHE_OPERATIONS_COLORS = {
CACHE_GET: "#007bff",
CACHE_PUT: "#4661EE",
@@ -35,28 +40,88 @@ const CACHE_OPERATIONS_COLORS = {
CACHE_INVOKE_ALL: "#fd7e14",
CACHE_PUT_ALL_CONFLICT: "#5289A4",
CACHE_REMOVE_ALL_CONFLICT: "#17807E",
- CACHE_LOCK: "#FAA586"
+ CACHE_LOCK: "#FAA586",
+ CACHE_LOAD: "#0050b3",
+ CACHE_LOAD_ALL: "#3366cc",
+ CACHE_LOAD_CACHE: "#5c7cfa",
+ CACHE_WRITE: "#2f9e44",
+ CACHE_WRITE_ALL: "#37b24d",
+ CACHE_DELETE: "#d6336c",
+ CACHE_DELETE_ALL: "#e8590c"
};
const searchCachesSelect = $('#searchCaches');
const searchNodesSelect = $('#searchNodes');
var opsCountPerType = {};
+var storeOpsCountPerType = {};
function drawCacheCharts() {
$("#operationsCharts").empty();
+ $("#operationsCharts").append('<div id="cacheOperationsCharts"><h2>Cache
operations</h2></div>');
+ $("#operationsCharts").append('<div id="storeOperationsCharts"><h2
class="mt-5">Cache store operations</h2></div>');
+
+ var cacheOperationsCharts = $("#cacheOperationsCharts");
+ var storeOperationsCharts = $("#storeOperationsCharts");
+
+ drawOperationCharts(cacheOperationsCharts, CACHE_OPERATIONS,
CACHE_OPERATIONS_READABLE, opsCountPerType);
+
+ drawBarChart(cacheOperationsCharts, "operationBarChart", CACHE_OPERATIONS,
opsCountPerType, 'Distribution of count operations by type');
+
+ drawOperationCharts(storeOperationsCharts, CACHE_STORE_OPERATIONS,
CACHE_STORE_OPERATIONS_READABLE, storeOpsCountPerType);
+
+ drawBarChart(storeOperationsCharts, "storeOperationBarChart",
CACHE_STORE_OPERATIONS, storeOpsCountPerType, 'Distribution of cache store
operations by type');
+}
+
+function prepareCacheDatasets(opName, countByType) {
+ var cacheId = searchCachesSelect.val();
+ var nodeId = searchNodesSelect.val();
+
+ var datasets = [];
+
+ var cacheOps = REPORT_DATA.cacheOps[nodeId] === undefined ? undefined :
REPORT_DATA.cacheOps[nodeId][cacheId];
+
+ if (cacheOps === undefined)
+ return datasets;
+
+ var datasetData = [];
+
+ $.each(cacheOps[opName], function (k, arr) {
+ datasetData.push({t: parseInt(arr[0]), y: arr[1]});
+
+ countByType[opName] += arr[1];
+ });
+
+ sortByKeyAsc(datasetData, "t");
+
+ var dataset = {
+ data: datasetData,
+ label: "Count of " + opName,
+ lineTension: 0,
+ backgroundColor: 'transparent',
+ borderWidth: 2,
+ pointRadius: 1,
+ borderColor: CACHE_OPERATIONS_COLORS[opName],
+ pointBackgroundColor: CACHE_OPERATIONS_COLORS[opName],
+ };
+
+ datasets.push(dataset);
- $.each(CACHE_OPERATIONS, function (k, opName) {
- opsCountPerType[opName] = 0;
+ return datasets;
+}
+
+function drawOperationCharts(container, operations, readableNames,
countPerType) {
+ $.each(operations, function (k, opName) {
+ countPerType[opName] = 0;
var chartId = opName + "OperationChart";
- $("#operationsCharts").append('<canvas class="my-4" ' + 'id="' +
chartId + '" height="120"/>');
+ container.append('<canvas class="my-4" id="' + chartId + '"
height="120"/>');
new Chart(document.getElementById(chartId), {
type: 'line',
data: {
- datasets: prepareCacheDatasets(opName)
+ datasets: prepareCacheDatasets(opName, countPerType)
},
options: {
scales: {
@@ -92,66 +157,31 @@ function drawCacheCharts() {
},
title: {
display: true,
- text: "Count of [" + CACHE_OPERATIONS_READABLE[k] + "]",
+ text: "Count of [" + readableNames[k] + "]",
fontSize: 20
},
animation: false
}
})
});
-
- drawCacheBar();
}
-function prepareCacheDatasets(opName) {
- var cacheId = searchCachesSelect.val();
- var nodeId = searchNodesSelect.val();
-
- var datasets = [];
-
- var cacheOps = REPORT_DATA.cacheOps[nodeId] === undefined ? undefined :
REPORT_DATA.cacheOps[nodeId][cacheId];
-
- if (cacheOps === undefined)
- return datasets;
-
- var datasetData = [];
+function drawBarChart(container, chartId, labels, countPerType, title) {
+ var html = '<canvas class="my-4" id="' + chartId + '" height="90"/>';
- $.each(cacheOps[opName], function (k, arr) {
- datasetData.push({t: parseInt(arr[0]), y: arr[1]});
+ var header = container.children("h2").first();
- opsCountPerType[opName] += arr[1];
- });
-
- sortByKeyAsc(datasetData, "t");
-
- var dataset = {
- data: datasetData,
- label: "Count of " + opName,
- lineTension: 0,
- backgroundColor: 'transparent',
- borderWidth: 2,
- pointRadius: 1,
- borderColor: CACHE_OPERATIONS_COLORS[opName],
- pointBackgroundColor: CACHE_OPERATIONS_COLORS[opName],
- };
-
- datasets.push(dataset);
-
- return datasets;
-}
-
-function drawCacheBar() {
- $("#operationsCharts").prepend('<canvas class="my-4"
id="operationBarChart" height="60"/>');
+ header.after(html);
var data = [];
var colors = [];
- $.each(CACHE_OPERATIONS, function (k, opName) {
- data[k] = opsCountPerType[opName];
+ $.each(labels, function (k, opName) {
+ data[k] = countPerType[opName];
colors[k] = CACHE_OPERATIONS_COLORS[opName];
});
- new Chart(document.getElementById("operationBarChart"), {
+ new Chart(document.getElementById(chartId), {
type: 'bar',
data: {
datasets: [{
@@ -159,7 +189,7 @@ function drawCacheBar() {
backgroundColor: colors,
label: 'Total count',
}],
- labels: CACHE_OPERATIONS
+ labels: labels
},
options: {
scales: {
@@ -180,13 +210,12 @@ function drawCacheBar() {
},
title: {
display: true,
- text: 'Distribution of count operations by type',
+ text: title,
fontSize: 20
},
animation: false
}
});
-
}
buildSelectCaches(searchCachesSelect, drawCacheCharts);
diff --git
a/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
b/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
index f7ca62b1..c53e9b6a 100644
---
a/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
+++
b/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
@@ -22,8 +22,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+import javax.cache.Cache;
+import javax.cache.configuration.FactoryBuilder;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -36,6 +39,7 @@ import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.query.IndexQuery;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeTaskAdapter;
@@ -54,18 +58,21 @@ import
org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
+import static java.lang.System.exit;
import static java.util.Collections.singletonMap;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.gt;
import static
org.apache.ignite.internal.processors.performancestatistics.AbstractPerformanceStatisticsTest.waitForStatisticsEnabled;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
import static
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
import static
org.apache.ignite.testframework.junits.GridAbstractTest.LOCAL_IP_FINDER;
+import static org.apache.ignite.testframework.junits.GridAbstractTest.doSleep;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -77,6 +84,9 @@ public class PerformanceStatisticsReportSelfTest {
/** Cache name. */
private static final String CACHE_NAME = "cache";
+ /** Cache with test third-party cache store. */
+ private static final String STORE_CACHE_NAME = "storeCache";
+
/** @throws Exception If failed. */
@Test
public void testCreateReport() throws Exception {
@@ -96,6 +106,11 @@ public class PerformanceStatisticsReportSelfTest {
.setKeyType(Integer.class.getName())
.setValueType(Integer.class.getName()))));
+ IgniteCache<Object, Object> storeCache = client.createCache(new
CacheConfiguration<>(STORE_CACHE_NAME)
+
.setCacheStoreFactory(FactoryBuilder.factoryOf(TestStore.class))
+ .setReadThrough(true)
+ .setWriteThrough(true));
+
cache.put(0, 0);
cache.put(1, 1);
cache.get(1);
@@ -115,6 +130,24 @@ public class PerformanceStatisticsReportSelfTest {
cachex.putAllConflict(singletonMap(keyConfl, new
GridCacheDrInfo(valConfl, confl)));
cachex.removeAllConflict(singletonMap(keyConfl, confl));
+ for (int i = 0; i < 100; i++) {
+ storeCache.put(i, i);
+
+ if (i % 2 == 0) {
+ storeCache.get(i);
+ storeCache.getAll(Set.of(-i, -i - 1));
+ storeCache.loadCache(null);
+ }
+
+ if (i % 3 == 0)
+ storeCache.putAll(Map.of(i, i, i + 1, i + 1));
+
+ if (i % 5 == 0) {
+ storeCache.remove(i);
+ storeCache.removeAll(Set.of(i, i + 1));
+ }
+ }
+
client.compute().run(() -> {
// No-op.
});
@@ -316,4 +349,29 @@ public class PerformanceStatisticsReportSelfTest {
return null;
}
}
+
+ /** Test delayed cache store. */
+ public static class TestStore extends CacheStoreAdapter<Object, Object> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object load(Object key) {
+ doSleep(10);
+
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<Object, Object> clo,
Object... args) {
+ doSleep(10);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Cache.Entry<?, ?> entry) {
+ doSleep(10);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void delete(Object key) {
+ doSleep(10);
+ }
+ }
}