This is something that i am struggling for a long time to understand what switches, flags or optimisations i am missing when writing to disk. below is the problem:
According to crystal-disk(benchmarking tool) my ssd(nvme) is capable of ~ approx 1GB/s sequential writes
I wrote a node.js application which does following but the maximum i am getting is 70MB/s what am i doing wrong?
I understand i wont be able to get full 1GB/s but the result i am getting is really a very small fraction of it to even belive this is actual disk speed.
let handle = fs.openSync(`filepath`, "as");
const payload = Array.from({ length: (1000000) }, (_, idx) => [idx.toString().padStart(20, "1"), idx.toString().padStart(20, "1"), idx.toString().padStart(20, "1"), idx.toString().padStart(20, "1")]);
while (for 5 sec) {
fs.appendFileSync(handle, payload.join());
fs.fsyncSync(handle);
fs.fdatasyncSync(handle);
}