听起来这个思路很像database里第二遍使用才进cache的想法,因为一次扫描cache就全没了。

Justin Wong <[email protected]>于2016年5月3日周二 12:17写道:

> 以前在 ustc 邮件列表看到过 mirrors 磁盘缓存几乎无效的问题,其中一个主要原因是 rsync 一遍就扫一遍磁盘,cache 全废了。
>
> 今天看到一个叫 nocache 的工具 https://github.com/Feh/nocache 可以禁止某个进程使用
> cache,进而发现除了 nocache 还有一些方案可以考虑。
>
> 一个是最暴力的方式是直接使用 cgroup 限制 rsync 的内存。我测了一下,效果拔群
>
> ```
> cgcreate -g memory:cptest
> cgset -r memory.limit_in_bytes=20M cptest  # 创建个 cgroup 并限制内存使用为 20MB
> dd if=/dev/zero of=test bs=1M count=2048   # 创建个2G的文件
> echo 3 > /proc/sys/vm/drop_caches              # 把已有的 cache drop 掉,这时
> free -m 应该看见 cache 的量很小了
>
> cgexec -g memory:cptest cp test test 1         # 在 cgroup 中复制一遍 test
> /nocache/cachestats ./test1                            # 用 nocache
> 提供的工具看一下 cache 情况,几乎没有被任何 cache
> > pages in cache: 1175/524288 (0.2%)  [filesize=2097152.0K, pagesize=4K]
>
> # 然后直接跑 cp,再用 cachestats 看一下
> cp test test1
> nocache/cachestats ./test1
> > pages in cache: 524288/524288 (100.0%)  [filesize=2097152.0K,
> pagesize=4K]
> # 全被 cache 住了
> ```
>
> 还有就是 http://insights.oetiker.ch/linux/fadvise.html 这个地方提供了一个 rsync 的
> patch,使用 fadvice 让 rsync 尽量不使用 cache。
>
> 感觉解决了一个老大难问题啊。
>
> --
> Justin Wong
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "TUNA 主邮件列表" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups "TUNA 
主邮件列表" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

回复