You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "dant3 (via GitHub)" <gi...@apache.org> on 2026/01/12 12:08:24 UTC

[PR] IGNITE-27357 add IO metrics [ignite-3]

dant3 opened a new pull request, #7387:
URL: https://github.com/apache/ignite-3/pull/7387

   https://issues.apache.org/jira/browse/IGNITE-27357


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "dant3 (via GitHub)" <gi...@apache.org>.
dant3 commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811838557


##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ,  0L);
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);

Review Comment:
   FilePageStoreIo doesn't have readFully/wrtieFully. However it's write/read methods utilize writeFully/readFully of the underlying FileIo which we test here.



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ,  0L);
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);
+
+            // Verify write metrics were recorded - 1 write of header + 1 write of page
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  PAGE_SIZE * 2);
+            assertDistributionMetricRecordsCount(metricSet, PageMemoryIoMetrics.WRITES_TIME, 2L);
+
+            // Perform read operation
+            long pageOff = filePageStoreIo.pageOffset(pageId);
+            ByteBuffer readBuffer = ByteBuffer.allocateDirect(PAGE_SIZE).order(java.nio.ByteOrder.nativeOrder());
+            filePageStoreIo.read(pageId, pageOff, readBuffer, false);

Review Comment:
   FilePageStoreIo doesn't have readFully/wrtieFully. However it's write/read methods utilize writeFully/readFully of the underlying FileIo which we test here.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811885640


##########
modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoMetrics.java:
##########
@@ -15,16 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.cli.core.style;
+package org.apache.ignite.internal.fileio;
 
 /**
- * Provider for the current color scheme.
+ * Metrics for file I/O operations.
  */
-public interface ColorSchemeProvider {
+public interface FileIoMetrics {
     /**
-     * Returns the current color scheme.
+     * Records a read operation.
      *
-     * @return Current color scheme, never null.
+     * @param bytesRead Number of bytes read (positive on success, 0 for EOF, -1 on error).
+     * @param durationNanos Operation duration in nanoseconds.
      */
-    ColorScheme colorScheme();
+    void recordRead(int bytesRead, long durationNanos);
+
+    /**
+     * Records a write operation.
+     *
+     * @param bytesWritten Number of bytes written (positive on success, 0 or -1 on error).

Review Comment:
   I see. but it says `0 or -1 on error` and it's not clear how to interpret it from the comment itself



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "dant3 (via GitHub)" <gi...@apache.org>.
dant3 commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811753785


##########
modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoMetrics.java:
##########
@@ -15,16 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.cli.core.style;
+package org.apache.ignite.internal.fileio;
 
 /**
- * Provider for the current color scheme.
+ * Metrics for file I/O operations.
  */
-public interface ColorSchemeProvider {
+public interface FileIoMetrics {
     /**
-     * Returns the current color scheme.
+     * Records a read operation.
      *
-     * @return Current color scheme, never null.
+     * @param bytesRead Number of bytes read (positive on success, 0 for EOF, -1 on error).
+     * @param durationNanos Operation duration in nanoseconds.
      */
-    ColorScheme colorScheme();
+    void recordRead(int bytesRead, long durationNanos);
+
+    /**
+     * Records a write operation.
+     *
+     * @param bytesWritten Number of bytes written (positive on success, 0 or -1 on error).

Review Comment:
   0 means nothing was read/written. Its not really an error I guess. For example while reading you reached end of the data stream, or you were trying to write in non-blocking channel but that channel couldn't write anything without blocking and hence gently refused to write. All of that are standard java nio behaviour.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811886751


##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ,  0L);
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);

Review Comment:
   I see, my mistake



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "dant3 (via GitHub)" <gi...@apache.org>.
dant3 commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811953757


##########
modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoMetrics.java:
##########
@@ -15,16 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.cli.core.style;
+package org.apache.ignite.internal.fileio;
 
 /**
- * Provider for the current color scheme.
+ * Metrics for file I/O operations.
  */
-public interface ColorSchemeProvider {
+public interface FileIoMetrics {
     /**
-     * Returns the current color scheme.
+     * Records a read operation.
      *
-     * @return Current color scheme, never null.
+     * @param bytesRead Number of bytes read (positive on success, 0 for EOF, -1 on error).
+     * @param durationNanos Operation duration in nanoseconds.
      */
-    ColorScheme colorScheme();
+    void recordRead(int bytesRead, long durationNanos);
+
+    /**
+     * Records a write operation.
+     *
+     * @param bytesWritten Number of bytes written (positive on success, 0 or -1 on error).

Review Comment:
   I fixed it



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "dant3 (via GitHub)" <gi...@apache.org>.
dant3 commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811753785


##########
modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoMetrics.java:
##########
@@ -15,16 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.cli.core.style;
+package org.apache.ignite.internal.fileio;
 
 /**
- * Provider for the current color scheme.
+ * Metrics for file I/O operations.
  */
-public interface ColorSchemeProvider {
+public interface FileIoMetrics {
     /**
-     * Returns the current color scheme.
+     * Records a read operation.
      *
-     * @return Current color scheme, never null.
+     * @param bytesRead Number of bytes read (positive on success, 0 for EOF, -1 on error).
+     * @param durationNanos Operation duration in nanoseconds.
      */
-    ColorScheme colorScheme();
+    void recordRead(int bytesRead, long durationNanos);
+
+    /**
+     * Records a write operation.
+     *
+     * @param bytesWritten Number of bytes written (positive on success, 0 or -1 on error).

Review Comment:
   0 means nothing was read/written. Its not an error. For example while reading you reached end of the data stream, or you were trying to write in non-blocking channel but that channel couldn't write anything without blocking and hence gently refused to write. All of that are standard java nio behaviour.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27357 add IO metrics [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811241155


##########
modules/file-io/src/main/java/org/apache/ignite/internal/fileio/MeteredFileIo.java:
##########
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.fileio;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+
+/**
+ * FileIo decorator that records metrics for read and write operations.
+ */
+public class MeteredFileIo implements FileIo {

Review Comment:
   I propose two "alternatives":
   - You can extend this class from `org.apache.ignite.internal.fileio.FileIoDecorator` to reduce the volume of unnecessary code.
   - Or you can introduce all such changes into `org.apache.ignite.internal.fileio.AbstractFileIo`, given that we will always use metrics for IO.
   
   I think I would prefer option 1, it's a bit more flexible. Both options would help us to track individual file access in methods like `readFully` or `writeFully`, instead of measuring an entire batch.



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ,  0L);
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);

Review Comment:
   Please either assert the result of `write` operation or use `writeFully`



##########
modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoMetrics.java:
##########
@@ -15,16 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.cli.core.style;
+package org.apache.ignite.internal.fileio;
 
 /**
- * Provider for the current color scheme.
+ * Metrics for file I/O operations.
  */
-public interface ColorSchemeProvider {
+public interface FileIoMetrics {
     /**
-     * Returns the current color scheme.
+     * Records a read operation.
      *
-     * @return Current color scheme, never null.
+     * @param bytesRead Number of bytes read (positive on success, 0 for EOF, -1 on error).
+     * @param durationNanos Operation duration in nanoseconds.
      */
-    ColorScheme colorScheme();
+    void recordRead(int bytesRead, long durationNanos);
+
+    /**
+     * Records a write operation.
+     *
+     * @param bytesWritten Number of bytes written (positive on success, 0 or -1 on error).

Review Comment:
   What does `0` mean? Is it success or error?



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ,  0L);
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);
+
+            // Verify write metrics were recorded - 1 write of header + 1 write of page
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  PAGE_SIZE * 2);
+            assertDistributionMetricRecordsCount(metricSet, PageMemoryIoMetrics.WRITES_TIME, 2L);
+
+            // Perform read operation
+            long pageOff = filePageStoreIo.pageOffset(pageId);
+            ByteBuffer readBuffer = ByteBuffer.allocateDirect(PAGE_SIZE).order(java.nio.ByteOrder.nativeOrder());
+            filePageStoreIo.read(pageId, pageOff, readBuffer, false);

Review Comment:
   Same comment is applied to `read`



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org