Andrey Yarovoy created HDDS-17717:
-------------------------------------

             Summary: OzoneFSInputStream should implement CanSetDropBehind as a 
no-op
                 Key: HDDS-17717
                 URL: https://issues.apache.org/jira/browse/HDDS-17717
             Project: Apache Ozone
          Issue Type: Improvement
          Components: Ozone Filesystem
            Reporter: Andrey Yarovoy


*Description*

`OzoneFSInputStream` implements `ByteBufferReadable`, `CanUnbuffer` and 
`ByteBufferPositionedReadable`, but not `CanSetDropBehind`. Hadoop's
`FSDataInputStream.setDropBehind` casts the wrapped stream to 
`CanSetDropBehind`, and on `ClassCastException` throws
`UnsupportedOperationException`. Both exceptions fill in a stack trace.

HBase calls `setDropBehind` on every stream it opens 
(`FSDataInputStreamWrapper.setStreamOptions`) and swallows the exception. On 
HBase every
store-file reopen (`StoreScanner.trySwitchToStreamRead`) opens two streams, so 
the exception is thrown twice per reopen per store file.

*Evidence (HBase YCSB on EC, RegionServer async-profiler JFR, 6×60s per arm)*

`FSDataInputStream.setDropBehind` → `UnsupportedOperationException.<init>` → 
`Throwable.fillInStackTrace` costs **0.75% (stream read ON) and
0.96% (OFF)** of RS CPU. That is pure exception cost; the call has no effect.

*Proposed fix*

{code:java}
public class OzoneFSInputStream extends FSInputStream
implements ByteBufferReadable, CanUnbuffer, ByteBufferPositionedReadable, 
CanSetDropBehind {
/** Drop-behind is a page-cache hint for the local client; Ozone reads go to 
datanodes, so it is accepted and ignored. */
@Override
public void setDropBehind(Boolean dropCache) {
}
}
{code}

- Same for the o3fs path; both share `OzoneFSInputStream`.
- `CapableOzoneFSInputStream.hasCapability(StreamCapabilities.DROPBEHIND)` 
keeps returning `false`. The stream accepts the hint but does not
implement it, so it should not advertise the capability. Callers that probe 
capabilities first see no change.

*Rejected alternative*

Forward the hint to the datanode (`fadvise`-style, like HDFS). That would be a 
protocol and feature change; the cost here is the exception.

*Compatibility / side effects*

`setDropBehind` stops throwing `UnsupportedOperationException`. Callers that 
treat the exception as "unsupported" (HBase logs and ignores it)
now see a silent no-op. No wire change.

*Tests*

- Unit: `setDropBehind(true/false/null)` on an ofs and an o3fs 
`FSDataInputStream` does not throw; `hasCapability("dropbehind")` stays false.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to