Memory and Storage Systems HW_1 report
===
## 310605006 羅懷虔
## Q0. example
==**Q0 Answer:**==
```bash=
job1: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
fio-3.28
Starting 1 process
job1: (groupid=0, jobs=1): err= 0: pid=615569: Thu Apr 13 17:13:49 2023
read: IOPS=40.0k, BW=156MiB/s (164MB/s)(1024MiB/6547msec)
clat (usec): min=20, max=14802, avg=24.77, stdev=53.59
lat (usec): min=20, max=14802, avg=24.79, stdev=53.59
clat percentiles (usec):
| 1.00th=[ 22], 5.00th=[ 22], 10.00th=[ 22], 20.00th=[ 22],
| 30.00th=[ 22], 40.00th=[ 22], 50.00th=[ 22], 60.00th=[ 22],
| 70.00th=[ 22], 80.00th=[ 23], 90.00th=[ 27], 95.00th=[ 48],
| 99.00th=[ 49], 99.50th=[ 55], 99.90th=[ 133], 99.95th=[ 137],
| 99.99th=[ 180]
bw ( KiB/s): min=79048, max=181512, per=100.00%, avg=160763.08, stdev=36328.03, samples=13
iops : min=19762, max=45378, avg=40190.77, stdev=9082.01, samples=13
lat (usec) : 50=99.32%, 100=0.48%, 250=0.19%, 500=0.01%
lat (msec) : 4=0.01%, 10=0.01%, 20=0.01%
cpu : usr=1.80%, sys=10.51%, ctx=262149, majf=0, minf=15
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=262144,0,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
READ: bw=156MiB/s (164MB/s), 156MiB/s-156MiB/s (164MB/s-164MB/s), io=1024MiB (1074MB), run=6547-6547msec
Disk stats (read/write):
sdc: ios=258972/2, merge=0/1, ticks=5863/11, in_queue=5884, util=98.60%
```
## Q1 read vs. randread on HDD
###
==**FIO Output:**==
```bash=
Run status group 0 (all jobs):
READ: bw=77.3MiB/s (81.0MB/s), 77.3MiB/s-77.3MiB/s (81.0MB/s-81.0MB/s), io=64.0MiB (67.1MB), run=828-828msec
Run status group 1 (all jobs):
READ: bw=3696KiB/s (3785kB/s), 3696KiB/s-3696KiB/s (3785kB/s-3785kB/s), io=64.0MiB (67.1MB), run=17730-17730msec
Disk stats (read/write):
sdc: ios=32028/0, merge=0/0, ticks=17770/0, in_queue=17771, util=98.13%
```
==**Q1 Answer:**==
- According to the **io bandwidth** , the io bandwidth of **read is greater than that of randread** because of different memory access patterns. Memory read refers to the process of reading data from a specific memory location in a sequential manner. The processor accesses the memory in a predictable pattern, fetching data from one memory location after another.
- On the contrary,randread refers to a random memory access pattern, where the processor accesses memory locations in a non-sequential and unpredictable manner.
- Memory read is faster than rand read because sequential memory access allows the processor to use the cache memory more effectively .Cache memory is designed to store recently accessed data, so when the processor accesses memory locations in a sequential manner, it can use the cache memory to quickly retrieve data and moving the head around the platter may spend a lot of time in randread.
## Q2-1 write vs. randwrite on HDD
==**FIO Outout:**==
```bash=
Run status group 0 (all jobs):
WRITE: bw=125MiB/s (131MB/s), 125MiB/s-125MiB/s (131MB/s-131MB/s), io=64.0MiB (67.1MB), run=514-514msec
Run status group 1 (all jobs):
WRITE: bw=7867KiB/s (8056kB/s), 7867KiB/s-7867KiB/s (8056kB/s-8056kB/s), io=64.0MiB (67.1MB), run=8330-8330msec
```
==**Q2-1 Answer:**==
- Similar to the **previous question**,memory write is faster than randwrite in HDD because **sequential memory access** allows the processor to use the cache memory more effectively,and randwriting may spend a lot of time to **move the head around the platter in HDD**.
## Q2-2 write vs. randwrite on SSD
==**FIO Output:**==
```bash=
Run status group 2 (all jobs):
WRITE: bw=120MiB/s (125MB/s), 120MiB/s-120MiB/s (125MB/s-125MB/s), io=64.0MiB (67.1MB), run=535-535msec
Run status group 3 (all jobs):
WRITE: bw=163MiB/s (171MB/s), 163MiB/s-163MiB/s (171MB/s-171MB/s), io=64.0MiB (67.1MB), run=393-393msec
Disk stats (read/write):
sdc: ios=0/32172, merge=0/1, ticks=0/8903, in_queue=9440, util=95.82%
sda: ios=0/22922, merge=0/0, ticks=0/599, in_queue=600, util=66.60%
```
==**Q2-2 Answer:**==
- Based on the design and operation principle of SSD,SSD has **no read head design**,so it has better performance for random access,so write and random write have about the same io bandwidth.
## Q3 forward write vs. backward write on HDD
==**FIO Output:**==
``` bash=
Run status group 0 (all jobs):
WRITE: bw=87.4MiB/s (91.7MB/s), 87.4MiB/s-87.4MiB/s (91.7MB/s-91.7MB/s), io=128MiB (134MB), run=1464-1464msec
Run status group 1 (all jobs):
WRITE: bw=14.2MiB/s (14.9MB/s), 14.2MiB/s-14.2MiB/s (14.9MB/s-14.9MB/s), io=128MiB (134MB), run=9032-9032msec
```
==**Q3 Answer:**==
- According to the io bandwidth, forward write is faster than backward read.
- Forward write refers to the process of writing data to the disk in a sequential manner from the outer edge of the platter towards the inner edge.This means that the data is written to consecutive sectors in a predictable and continuous manner. The advantage of this approach is that it enables the HDD's read/write head to write data faster and with greater efficiency because the head can remain in one position and write the data as the disk rotates beneath it.
- Backward write writes the data in a reverse sequential order from inner to outer. It is less efficient method .
## Q4-1 buffered read vs. nonbuffered read on SSD
==**FIO Output:**==
``` bash=
Run status group 0 (all jobs):
READ: bw=503MiB/s (527MB/s), 503MiB/s-503MiB/s (527MB/s-527MB/s), io=256MiB (268MB), run=509-509msec
Run status group 1 (all jobs):
READ: bw=174MiB/s (182MB/s), 174MiB/s-174MiB/s (182MB/s-182MB/s), io=256MiB (268MB), run=1474-1474msec
```
==**Q4-1 Answer:**==
- Comparing the bandwidth , buffer read is faster than non-buffer read
- In buffered read, data is read from the SSD into a buffer or cache in the computer's memory before being sent to the application or process requesting the data,which allows the computer to access the data more quickly since it doesn't have to wait for the SSD to retrieve.
- In non-buffer read ,data is read directly from the SSD and sent to the application or process requesting the data without being first copied to a buffer or cache in the computer's memory. This means that the computer has to wait for the SSD to retrieve the data every time it's requested .
## Q4-2 buffered read vs. nonbuffered randread on SSD
==**FIO Output:**==
``` bash=
Run status group 0 (all jobs):
READ: bw=20.1MiB/s (21.0MB/s), 20.1MiB/s-20.1MiB/s (21.0MB/s-21.0MB/s), io=256MiB (268MB), run=12767-12767msec
Run status group 1 (all jobs):
READ: bw=20.0MiB/s (21.0MB/s), 20.0MiB/s-20.0MiB/s (21.0MB/s-21.0MB/s), io=256MiB (268MB), run=12775-12775msec
```
==**Q4-2 Answer:**==
- In SSD , wear-leveling , which ensures that data is evenly distributed across the drive to minimize the need for random I/O operations. The performance impact of using a buffer for randread operations is minimal.
Therefore, both buffered randread and non-buffered randread can achieve similar read performance in SSD
## Q5 LBA on HDD
==**FIO Outout:**==
``` bash=
Run status group 0 (all jobs):
WRITE: bw=157MiB/s (165MB/s), 157MiB/s-157MiB/s (165MB/s-165MB/s), io=1024MiB (1074MB), run=6509-6509msec
Run status group 1 (all jobs):
WRITE: bw=190MiB/s (199MB/s), 190MiB/s-190MiB/s (199MB/s-199MB/s), io=1024MiB (1074MB), run=5396-5396msec
Run status group 2 (all jobs):
WRITE: bw=230MiB/s (241MB/s), 230MiB/s-230MiB/s (241MB/s-241MB/s), io=1024MiB (1074MB), run=4461-4461msec
Run status group 3 (all jobs):
WRITE: bw=233MiB/s (244MB/s), 233MiB/s-233MiB/s (244MB/s-244MB/s), io=1024MiB (1074MB), run=4396-4396msec
Run status group 4 (all jobs):
WRITE: bw=247MiB/s (259MB/s), 247MiB/s-247MiB/s (259MB/s-259MB/s), io=1024MiB (1074MB), run=4153-4153msec
```
==**Q5 Answer:**==
- As the offset decreases,the bandwidth may increase.The reason is that the higher the offset, the offset means starting point of the HDD.
- The starting point is located at the beginning of the device, for example, the I/O bandwidth may be higher due to the faster transfer rates at the outer tracks of the disk platter. Similarly, if the starting point is located towards the end of the device, the I/O bandwidth may be lower due to the slower transfer rates at the inner tracks of the disk platter.
## Q6 blocksize on HDD
==**FIO Outout:**==
``` bash=
Run status group 0 (all jobs):
WRITE: bw=102MiB/s (107MB/s), 102MiB/s-102MiB/s (107MB/s-107MB/s), io=1024MiB (1074MB), run=10042-10042msec
Run status group 1 (all jobs):
WRITE: bw=40.1MiB/s (42.0MB/s), 40.1MiB/s-40.1MiB/s (42.0MB/s-42.0MB/s), io=1024MiB (1074MB), run=25566-25566msec
```
==**Q6-1 Answer:**==
The io bandwidth is higher when blocksize is higher.The block size in bytes used for I/O units .
Small block sizes can result in more overhead: When data is written in smaller blocks, the operating system needs to issue more write commands to the storage device to write the same amount of data. This can result in more overhead and slower write speeds.
Larger block sizes can improve throughput: When data is written in larger blocks, the operating system can issue fewer write commands to the storage device to write the same amount of data. This can result in improved throughput and faster write speeds.
==**Q6-2 Answer:**==
- According to the above answers, increasing the blocksizes can reduce write commands to the storage device to write the same amount of data but bs size usually has limitation of maximum bs size due to different data or storage system .
- It could test for serveral times and check bandwidth, IOPS or latency to choose the best one
## Q7 Fastest nonbuffered write on HDD
==**FIO Output:**==
``` bash=
Run status group 0 (all jobs):
WRITE: bw=101MiB/s (106MB/s), 101MiB/s-101MiB/s (106MB/s-106MB/s), io=1024MiB (1074MB), run=10106-10106msec
Run status group 1 (all jobs):
WRITE: bw=205MiB/s (215MB/s), 205MiB/s-205MiB/s (215MB/s-215MB/s), io=1024MiB (1074MB), run=4990-4990msec
Run status group 2 (all jobs):
WRITE: bw=249MiB/s (261MB/s), 249MiB/s-249MiB/s (261MB/s-261MB/s), io=1024MiB (1074MB), run=4110-4110msec
Run status group 3 (all jobs):
WRITE: bw=245MiB/s (257MB/s), 245MiB/s-245MiB/s (257MB/s-257MB/s), io=1024MiB (1074MB), run=4176-4176msec
```
==**Q7 Answer:**==
- Test serval value of blocksize could find that **increasing bs can improve the io bandwidth** but has **a limitation (group2 and 3)** , bs=16k and 32k have the same io bandwitdh.
## Bonus for Q1
==**FIO Output:**==
``` bash=
Run status group 0 (all jobs):
READ: bw=173MiB/s (181MB/s), 173MiB/s-173MiB/s (181MB/s-181MB/s), io=64.0MiB (67.1MB), run=370-370msec
Run status group 1 (all jobs):
READ: bw=36.3MiB/s (38.1MB/s), 36.3MiB/s-36.3MiB/s (38.1MB/s-38.1MB/s), io=64.0MiB (67.1MB), run=1762-1762msec
```
==**Bonus Q1 Answer:**==
- When reading sequentially from an SSD, the controller can optimize the read operation by reading large blocks of data at once, which reduces the time needed to access individual memory cells. In contrast, when performing random reads, the controller must frequently switch between different memory cells, which can result in additional latency and slower performance.
## Bonus for Q2
==**FIO Output:**==
``` bash=
Run status group 0 (all jobs):
WRITE: bw=116MiB/s (121MB/s), 116MiB/s-116MiB/s (121MB/s-121MB/s), io=128MiB (134MB), run=1106-1106msec
Run status group 1 (all jobs):
WRITE: bw=90.3MiB/s (94.7MB/s), 90.3MiB/s-90.3MiB/s (94.7MB/s-94.7MB/s), io=128MiB (134MB), run=1417-1417msec
```
==**Bonus Q2 Answer:**==
- In general , the difference between forward and backward is small becaues SSD do not have mechanical head. The sequential access effect slightly effect.
- However from the result **io bandwidth** of forward write is faster .