unacceptably slow filesystem access - possible causes?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: unacceptably slow filesystem access - possible causes?

Post by onlyonemac »

mariuszp wrote:I still need to do some optimisations for the writes (currently I just invalidate the cached pages that contain the sector being written; I am planning to make it so that it updates the cache after while writing to disk in parallel).
That is a bad idea. If there are going to be multiple writes to the same "page", you want to buffer those. Standard procedure is to buffer the writes (i.e. to write them to the cached "page" only) and then flush the buffer to disk (write the invalidated "pages" to disk) when the buffer needs to be cleared or (in the interest of maintaining data integrity) at fixed intervals (say, every 10 seconds).
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: unacceptably slow filesystem access - possible causes?

Post by mariuszp »

I should probably implement write caching as @onlyonemac suggests, but currently during the development stage i'm worried i'll forget to "poweroff" or "sync" and instead terminate the VM immediately and break the filesystem. Would it really be a significant problem if I'm writing to disk in parallel using DMA?

Does the disk controller take (almost) the same amount of time to read a cylinder compared to reading 8 consecutive sectors?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: unacceptably slow filesystem access - possible causes?

Post by Combuster »

You can, at least for testing, enforce a sync() to complete whenever a file gets close()'d.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: unacceptably slow filesystem access - possible causes?

Post by mariuszp »

Well, that is done and the speed has greatly improved. I still need to implement prefetching because the GUI takes a few seconds to load the wallpaper.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: unacceptably slow filesystem access - possible causes?

Post by onlyonemac »

mariuszp wrote:I should probably implement write caching as @onlyonemac suggests, but currently during the development stage i'm worried i'll forget to "poweroff" or "sync" and instead terminate the VM immediately and break the filesystem.
If you flush the disk buffer every e.g. 10 seconds as I suggested, then as long as your VM (or computer) is idle for at least that period of time then you won't corrupt anything by terminating it (which is exactly why we flush the disk buffer every few seconds).
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Post Reply