Docsity

File System Performance: Memory-Mapped Files, Buffer Caches, and Log-Structured FS - Prof., Study notes of Operating Systems

Toggle sidebar
bg1
CS 333
Introduction to Operating Systems
Class 18 - File System Performance
Jonathan Walpole
Computer Science
Portland State University
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54

Partial preview of the text

Download File System Performance: Memory-Mapped Files, Buffer Caches, and Log-Structured FS - Prof. and more Study notes Operating Systems in PDF only on Docsity!

CS 333

Introduction to Operating Systems

Class 18 - File System Performance

Jonathan Walpole Computer Science Portland State University

Improving file system performance

‰ Memory mapped files ™ Avoid system call overhead ‰ Buffer cache ™ Avoid disk I/O overhead ‰ Careful data placement on disk ™ Avoid seek overhead ‰ Log structured file systems ™ Avoid seek overhead for disk writes (reads hit in buffercache)

Memory-mapped files

‰

Why not “map” files into the virtual address space

™ Place the file in the “virtual” address space ™ Each byte in a file has a virtual address ‰

To read the value of a byte in the file:

™ Just load that byte’s virtual address

Calculated from the starting virtual address of the fileand the offset of the byte in the file ™ Kernel will fault in pages from disk when needed ‰

To write values to the file:

™ Just store bytes to the right memory locations ‰ Open & Close syscalls

Map & Unmap syscalls

Memory-mapped files

‰ Virtual Address Space Stack Text & Data File on Disk

Memory-mapped files

‰ Virtual Address Space Stack Text & Data File on Disk “Map” syscall is made

Memory-mapped files

‰ Virtual Address Space Stack Text & Data File on Disk “Map” syscall is made

File system performance

‰ So how does memory mapping a file affect performance?

Buffer cache

‰ Observations: ™ Once a block has been read into memory it can be used toservice subsequent read/write requests without going todisk ™ Multiple file operations from one process may hit thesame file block ™ File operations of multiple processes may hit the samefile block ‰ Idea: maintain a “

block cache” (or “

buffer cache”) in

memory ™ When a process tries to read a block check the cachefirst

Buffer cache

‰ Cache organization: ™ Many blocks (e.g., 1000s) ™ Indexed on block number ‰ For efficiency, ™ use a hash table device block# key

Buffer Cache

‰

Buffer cache

‰ Need to write a block? ™ Modify the version in the block cache. ‰ But when should we write it back to disk? ™ Immediately ™ Later

Buffer cache

‰ Need to write a block? ‰ Modify the version in the block cache. ‰ But when should we write it back to disk? ™ Immediately

“ Write-through cache” ™ Later - The Unix “sync” syscall

Buffer cache

‰ Need to write a block? ™ Modify the version in the block cache. ‰ But when should we write it back to disk? ™ Immediately

“ Write-through cache” ™ Later - The Unix “synch” syscall ‰

What if system crashes?

‰

Can the file system become inconsistent?

™ Write directory and i-node info immediately ™ Okay to delay writes to files

Background process to write dirty blocks

File system performance

‰

How does a buffer cache improve file systemperformance?