I was just thinking about the linux vm swappiness algorithm. High
swappiness has a bad effect on some systems and although the kernel vm
is very well tuned these days the solution is more practical and not
theorotical. In extreme cases the situation _could_ render system
unusable for atleast few seconds.
Neways so i was just trying to fugire out what will be a theorotical
way to prevent swap thrash or atleast its ill effects. So that i will
be garunteed of responsiveness at all times. I kept bumping into
endless loops and complex algorithms.High complexity would defeat the
purpose of making things responsive. Then it struck me. I should just
use a watch dog and just halt the things if i try to use too old pages
and make it artificially costly to have things swapped in based on
thier last swapped in timestamp and total use count. (this is not a
discussion about the algo per say, after a little thought i did reach
a conclusion that this is as impractical as other hundred or so ideas
i have,)
What struck me the most is the human memory like behaviour this end
algo will emmulate. The more the memory is accessed the more hot it
will become. The less it is used the colder it will be and longer it
will take to recall it and eventually some memory will be just too
hard to recall. It will be still there and theorotically it will be
recallable if the system goes blank for enough time.But it will be
impossible to recall it if system is not totally relaxed . Is that how
our brain works? Think about it. Its exact behaviour we encounter.
Sometimes things just can't be recalled no matter how much you try.
Then suddenly after waking up or after a relaxing bath you recall
them. So may be our brains just work like the modified swapping VM.
Preventing swap thrash by denying the recall unless enough resources
are available. Allowing critical and interactive things to be always
hot and responsive.
Another implication is that we never forget anything we just lock it
out and we might train ourselves to do it volunterily. Sort of hacking
out the brain's vm. All we have to do is to make it expensive to
recall something. One very easy and wellknown way is time. Don't think
about it for long time and you are done. But there might be other
quicker ways. Like associating long banks of information with one
thing. Just associate too much info to the things you want to forget
and it will become expensive enough that you will not recall it even
if you want it to.
It should work other way round. A common technique used to keep things
hot is to associate the thing you want to remember with already hot
memory meaning never to be swapped out. But to make it long term one
of the ways could be remembering things in bits. Rather than storing
large pices glued together split it up and try to remember each bit
separately. The swap cost will be drmamatically reduced and so will
the recallability. (important note here: the practial pc swap is more
efficient when there are large data swaps, mainly becasue of the
characterstics of the storage media i.e. harddisks seek times. I
beleive brain has random access or some sort of radix scalable
indexing so that effect won't be applicable)
So what do you think??
Heh i can't even remember what the first line said as i have scrlled
passed it :(. May be some VM's are just bad no matter what.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment