hdparm --direct에서 캐시 읽기가 디스크 읽기보다 느린 이유는 무엇입니까?

hdparm --direct에서 캐시 읽기가 디스크 읽기보다 느린 이유는 무엇입니까?

hdparm의 결과를 해석하려고 합니다.

janus@behemoth ~ $ sudo hdparm  -Tt --direct /dev/nvme0n1

/dev/nvme0n1:
 Timing O_DIRECT cached reads:   2548 MB in  2.00 seconds = 1273.69 MB/sec
 Timing O_DIRECT disk reads: 4188 MB in  3.00 seconds = 1395.36 MB/sec

캐시된 읽기가 직접 디스크 읽기보다 어떻게 느려질 수 있는지 이해가 되지 않습니다. --direct를 제거하면 예상한 결과가 나타납니다. 즉, 디스크 읽기가 캐시된 읽기보다 느립니다.

janus@behemoth ~ $ sudo hdparm  -Tt /dev/nvme0n1

/dev/nvme0n1:
 Timing cached reads:   22064 MB in  2.00 seconds = 11042.86 MB/sec
 Timing buffered disk reads: 2330 MB in  3.00 seconds = 776.06 MB/sec

(이제 "버퍼된 디스크 읽기"라고 표시되지만).

누군가 나에게 무슨 일이 일어나고 있는지 설명해 줄 수 있습니까?

답변1

매뉴얼 hdparm페이지 기준:

--direct

Use the kernel´s "O_DIRECT" flag when  performing  a  -t  timing
test.   This  bypasses  the  page cache, causing the reads to go
directly from the drive into hdparm's buffers,  using  so-called
"raw"  I/O.  In many cases, this can produce results that appear
much faster than the usual page cache method,  giving  a  better
indication of raw device and driver performance.

hdparm -t --direct이는 왜 hdparm -t.--direct-t-T

-T 

Perform timings of cache reads for benchmark and comparison pur‐
poses.   For  meaningful  results,  this  operation  should   be  
repeated  2-3  times  on  an otherwise inactive system (no other
active processes) with at least a couple of  megabytes  of  free
memory.   This  displays  the speed of reading directly from the 
Linux buffer cache without disk  access.   This  measurement  is  
essentially  an  indication  of the throughput of the processor,
cache, and memory of the system under test.

-T디스크의 동일한 캐시 부분을 읽어 작업하고 싶습니다 . 그런데 --direct그걸 막으셨어요. 따라서 논리적으로 -t --direct와 동일한 결과를 얻어야 합니다 -T --direct.

답변2

제가 조사한 바에 따르면 --direct하드 드라이브를 통해 획득한 모든 데이터는 적어도 한 번은 전송됩니다. 즉, 시스템 캐시가 10GB/초의 속도로 데이터를 가져오는데 불량한 하드 드라이브 컨트롤러가 400MB/초의 속도로 정체되면 400MB/초를 얻게 됩니다.

리뷰로

  • -Tt --direct두 번 실행:

      1. 시스템 캐시를 읽고 이를 하드 드라이브 컨트롤러로 보낸 후 다시 보냅니다. 이는 SATA 연결 및 최대 버퍼 속도를 테스트하는 데 유용할 수 있습니다.
      1. 버퍼 없이 디스크에서 읽습니다.
  • -T시스템 캐시를 직접 읽고 프로세서 및 RAID 드라이버 오버헤드를 테스트합니다.

  • -t버퍼가 활성화된 디스크에서 읽기

관련 정보