View previous topic :: View next topic |
Author |
Message |
mansniks Apprentice
Joined: 19 Nov 2007 Posts: 290
|
Posted: Mon Aug 25, 2008 6:35 pm Post subject: OS partially in RAM? |
|
|
Is there some good way to put some most often used files in memory, so they don't need to be read from disk and it can be suspended (while OS is still functional)? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54387 Location: 56N 3W
|
Posted: Mon Aug 25, 2008 7:28 pm Post subject: |
|
|
mansniks,
Linux does this for you. When a file is read (any file) its buffered in RAM in case its needed again.
Eventually, when there is almost no RAM free, the kernel begins to reallocate memory. However before this happens, memory that has been allocated by rarely used processes (e.g. things needed only at startup and shut down) are moved to swap.
In short, you need do nothing special. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
mansniks Apprentice
Joined: 19 Nov 2007 Posts: 290
|
Posted: Mon Aug 25, 2008 9:51 pm Post subject: |
|
|
Well, if that could be all, I'd be happy...
Complete, indeterminately long disk suspend is necessary in case when no non-OS files are accessed for some time.
I tried similar thing with my laptop and now plan building my very custom file server, that should be able to do that. The thing is: I couldn't make my laptop stop turning disk on time after time with gentoo... Even if in black console only. |
|
Back to top |
|
|
notHerbert Advocate
Joined: 11 Mar 2008 Posts: 2228 Location: 45N 73W
|
|
Back to top |
|
|
zixnub n00b
Joined: 27 Dec 2007 Posts: 67 Location: Brasschaat, Belgium
|
Posted: Mon Aug 25, 2008 11:43 pm Post subject: |
|
|
NeddySeagoon wrote: | mansniks,
Linux does this for you. When a file is read (any file) its buffered in RAM in case its needed again.
Eventually, when there is almost no RAM free, the kernel begins to reallocate memory. However before this happens, memory that has been allocated by rarely used processes (e.g. things needed only at startup and shut down) are moved to swap.
In short, you need do nothing special. |
Yes but isn't this only after data has been read for the first time? I believe there are daemons that preload often used program into ram, this makes the system start up slower but makes often used programs launch faster. _________________ https://github.com/udevbe/greenfield
https://github.com/udevbe/westfield |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54387 Location: 56N 3W
|
Posted: Tue Aug 26, 2008 10:33 am Post subject: |
|
|
zixnub,
You can move things into tmpfs, which is in RAM to begin with. It may get moved to swap if RAM is needed, which defeats the use of tmpfs in the first place, since you will wait for your tmpfs to load at startup, then wait for things it contains to be loaded from swap.
You may make a permanent filesystem in RAM too. This is the same as making your RAM smaller as you now have two copies of things it contains. One in use, the other in the RAM filesystem. You get more swapping as a result, including RAM to RAM swapping, which is done by PIO, as the PC has no RAM to RAM DMA. This PIO flushes the CPU cache too, which is another bad thing.
The last think you can try to speed up load times is prelinking, which was new and broken when I played with it last several years ago. Things are still loaded into RAM on first use but some dynamic linker steps are removed, so its faster than normal dynamic link loading.
In short, memory management is a compromise. Speed ups in one area result in slowdowns and waste in another. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
notHerbert Advocate
Joined: 11 Mar 2008 Posts: 2228 Location: 45N 73W
|
|
Back to top |
|
|
mansniks Apprentice
Joined: 19 Nov 2007 Posts: 290
|
Posted: Tue Aug 26, 2008 12:13 pm Post subject: |
|
|
>In short, memory management is a compromise. Speed ups in one area result in slowdowns and waste in another.
I hardly doubt it could be worse to copy things RAM>RAM than HDD>RAM.
So how could I keep kernel logs and binaries (/bin, /sbin, /usr/bin ...) in RAM? What is really done in distros like DSL and Alpine? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54387 Location: 56N 3W
|
Posted: Tue Aug 26, 2008 2:49 pm Post subject: |
|
|
mansniks,
Well, ram to ram copies tie up your CPU 100% and flush the CPU cache, so when the CPU goes back to doing something useful, everyting has to be fetched from your much lower (than CPU cache) main RAM.
HDD to RAM is slower overall but the CPU involvement is writing a few words to the DMA engine, then getting on with something else while it waits on the disk transfer to complete. The CPU cache is not poisoned either.
You are thinking single threaded operation. The kernel memory manager tries to provide the best service it can to all threads and resolve conflicts with minimum impact to all threads.
DSL and its like can run entirely from RAM as they are so small. Tin Hat Linux is a secure 4GB+ Gentoo based system that is entirely RAM based. Its intended for servers. The Gentoo Linux minimal CD can do this too. Its intended to allow the CDROM to be unmounted so the install can continue using other CDs.
You can move /var/log and and directory you like to tmpfs but its all gone if you lose power. That not good for logs. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
mansniks Apprentice
Joined: 19 Nov 2007 Posts: 290
|
Posted: Tue Aug 26, 2008 5:07 pm Post subject: |
|
|
NeddySeagoon,
may I ask about TinHat: why it doesn't experience (I guess) difficulties with RAM>RAM? Some other, new technology you mentioned above? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54387 Location: 56N 3W
|
Posted: Tue Aug 26, 2008 5:20 pm Post subject: |
|
|
mansniks,
I don't know TIn Hat very well. You load a huge RAM image and of it goes.
I'm not sure if it even starts from a real everything on a filesystem and goes through an init process or not or if its a suspend to disk image that you load and resume. Here are the detials _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
|