Skip to content

HDDS-14219. Add metrics for ReadBlock#9535

Open
rich7420 wants to merge 6 commits intoapache:masterfrom
rich7420:HDDS-14219
Open

HDDS-14219. Add metrics for ReadBlock#9535
rich7420 wants to merge 6 commits intoapache:masterfrom
rich7420:HDDS-14219

Conversation

@rich7420
Copy link
Contributor

What changes were proposed in this pull request?

This PR adds metrics tracking for readBlock operations and unit test.

What is the link to the Apache JIRA

HDDS-14219

How was this patch tested?

test all passed locally.
https://github.com/rich7420/ozone/actions/runs/20390167387/

@swamirishi swamirishi requested a review from jojochuang January 5, 2026 17:57
}
};

RandomAccessFileChannel blockFile = new RandomAccessFileChannel();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must call close() on this object to release file description upon close.

RandomAccessFileChannel should have been made a Closeable object. Too bad that's not the case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,get it!
thanks for the review!

Copy link
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I added this comment too but it didn't show up before. Sorry for back and forth.

// TODO metrics.incContainerBytesStats(Type.ReadBlock, readBlock.getLen());
final ReadBlockRequestProto readBlock = request.getReadBlock();
final BlockID blockID = BlockID.getFromProtobuf(readBlock.getBlockID());
final BlockData blockData = getBlockManager().getBlock(kvContainer, blockID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an expensive operation because it involves reading from rocksdb. And for the most part this blockData is not going to be used since readBlock usually has length. So this is a waste.

IMO, we should let readBlockImpl() to return the length it actually read and use that as the counter for bytesRead.

Copy link
Contributor

@jojochuang jojochuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request change not approval.

@rich7420
Copy link
Contributor Author

rich7420 commented Jan 14, 2026

I've tried to resolve this problem and update.

@ss77892
Copy link
Contributor

ss77892 commented Jan 22, 2026

We should also update the Volume statistic. Something like:

  final long startTime = Time.monotonicNow();
  final long bytesRead = readBlockImpl(request, blockFile, kvContainer, streamObserver, false);
  long endTime = Time.monotonicNow();
  KeyValueContainerData containerData = (KeyValueContainerData) kvContainer
      .getContainerData();
  HddsVolume volume = containerData.getVolume();
  if (volume != null) {
    volume.getVolumeIOStats().incReadTime(endTime - startTime);
    volume.getVolumeIOStats().incReadOpCount();
    volume.getVolumeIOStats().incReadBytes(bytesRead);
  }

@jojochuang
Copy link
Contributor

@ss77892 IMO the volume level metrics should be updated within RandomAccessFileChannel itself.

But yeah, since this request readBlock does not use the regular ChunkUtils/FilePerBlockStrategy, volume level metrics are not automatically updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants