mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sitsofe Wheeler <sitsofe@yahoo.com>
To: Alexey Fisher <bug-track@fisher-privat.net>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: smart cache. ist is possible?
Date: Mon, 16 Mar 2009 17:36:09 +0000	[thread overview]
Message-ID: <20090316173609.GB10814@silver.sucs.org> (raw)
In-Reply-To: <49BE011D.5080807@fisher-privat.net>

On Mon, Mar 16, 2009 at 08:34:53AM +0100, Alexey Fisher wrote:
> 
> If i read same somefile second time, normally will happen the same. It
> tries to read block 1 and  this is not it cache, so it will be cached
> and move block 6 out. ( |1|7|8|9|10| ) So it will complete replace
> entire cache.

Yup, that's my understanding (I'm no pro on this stuff though).
Different cache replacement algorithms will have different behviour
though (I believe Linux uses some variation on LRU -
http://linux-mm.org/AdvancedPageReplacement ).

> Or i can say, read somefile and only blocks 6-10 so i can use
> performance from cache.

Yup, you could do this but your code would have to have exactly this in
mind (e.g. skip the first 7 Mbytes THEN read 10 mbytes). There's nothing
automatic happening in this scenario from the cache's perspective -
you're just reading less so it (hopefully) doesn't become full and evict
what you want it to keep.

> Or OS need to get a list of blocks from somefile and list of cached
> blocks. And check if there is some of them cached. If they are, it
> should lock the cache, read 1-5 without caching it and read 6-10 from
> cache. After this unlock the cache. But this is not possible because
> this operation is to expensive.
> Is this what you mean?

Kinda. More like when you use memory mapped I/O (mmap) you can "lock"
pieces of the file into ram (and thus have those pieces always in
cache). See mlock -
http://opengroup.org/onlinepubs/007908799/xsh/mlock.html . There are
usually restrictions on just how much memory you can lock etc.

-- 
Sitsofe | http://sucs.org/~sits/

  reply	other threads:[~2009-03-16 17:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-15 15:28 Alexey Fisher
2009-03-15 18:13 ` Sitsofe Wheeler
2009-03-15 22:06   ` Alexey Fisher
2009-03-15 23:26     ` Sitsofe Wheeler
2009-03-16  7:34       ` Alexey Fisher
2009-03-16 17:36         ` Sitsofe Wheeler [this message]
2009-03-15 22:23 ` Dave Chinner
2009-03-16 13:02 ` Pádraig Brady
2009-03-16 15:15 ` Paulo Marques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090316173609.GB10814@silver.sucs.org \
    --to=sitsofe@yahoo.com \
    --cc=bug-track@fisher-privat.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®