cache和buff cache的区别

Cache和Buffer的区别_百度知道
Cache和Buffer的区别
我有更好的答案
以下就 Cache 和 Buffer 之间最根本的区别说明一下:* Cache 一般翻译为“高速缓存”或简称“缓存”,一般当出现“传输或存储上的效率层级”时,Cache 才会出现,它的作用就是 [把效率低一级的最常数据用效率高但容量小的存储容器存放],比如CPU Cache相对于内存、内存相对于磁盘、磁盘相对于网络传输,这些都是高效率相对低效率存储/传输的实例。所以 Cache 中的数据又有暂时性。在编程中当需要提高整个系统工作效率时,才会启用或实现 Cache 机制(比如在大数据处理中使用 memcache)。* 而 Buffer 一般翻译为“缓冲区”,它对于数据传输和存储没有“上下效率层级”的概念,上传下、下传上、平级之间都会用到 Buffer,它通常的意义是指 [模块与模块之间用于取得或传递数据的存储空间]。在编程中 Buffer 要比 Cache 的概念用的多的多,比如调用函数 buf[256]; fgets(buf, 256, fp) 的意义就是将 C 运行库标准输入模块的数据传递到用户程序模块中。
采纳率:83%
来自团队:
为您推荐:
其他类似问题
cache的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。欢迎访问"运维那点事",推荐使用Google浏览器访问,可以扫码关注本站的"微信公众号"。
如果您觉得本站对你有帮助,那么可以扫码捐助以帮助本站更好地发展。
一、hcache
Linux用户可能经常遇到的一个问题是内存大部分都被Buffer和Cache占用了,但是有时候我们想知道到底Cache了些什么内容却没有一个直观好用的工具。今天给你介绍一个可以查看Linux当前缓存了哪些文件的小工具hcache。
Hcache作者:
前几天看到有个人用go写了个,可以查看某个文件是否被缓存(作者的目的是数据库调优),也可以根据进程pid来查看都缓存了哪些文件,但是不能查看整个操作系统都cache了哪些文件。因此,我基于pcstat写了个hcache,增加了查看当前操作系统cache的前top个文件的特性,你可以从下载下来试用,如果有什么建议的话也欢迎反馈给我:
官网:https://github.com/silenceshell/hcache
hcache是使用GO开发的,安装非常简单,开箱即用。
$ wget http://7xir15.com1.z0.glb.clouddn.com/hcache
$ chmod +x hcache
$ mv hcache /usr/local/bin/
$ wget http://7xir15.com1.z0.glb.clouddn.com/hcache$ chmod +x hcache$ mv hcache /usr/local/bin/
buff/cache
$ free -m&&&&&&&&&&&&&&total&&&&&&&&used&&&&&&&&free&&&&&&shared&&buff/cache&& availableMem:&&&&&&&&&& 7823&&&&&&&&1952&&&&&&&& 174&&&&&&&&&& 9&&&&&&&&5696&&&&&&&&5518Swap:&&&&&&&&&&&& 0&&&&&&&&&& 0&&&&&&&&&& 0
查看使用Cache最多的3个进程。
$ hcache --top 3
+----------------------------+----------------+------------+-----------+---------+
| Size (bytes)
| Percent |
|----------------------------+----------------+------------+-----------+---------|
| /usr/bin/dockerd
| 100.000 |
| /usr/bin/docker-containerd | 7115584
| 100.000 |
| /etc/udev/hwdb.bin
| 100.000 |
+----------------------------+----------------+------------+-----------+---------+
$ hcache --top 3+----------------------------+----------------+------------+-----------+---------+| Name&&&&&&&&&&&&&&&&&&&&&& | Size (bytes)&& | Pages&&&&&&| Cached&&&&| Percent ||----------------------------+----------------+------------+-----------+---------|| /usr/bin/dockerd&&&&&&&&&& | &&&&&& | 8147&&&&&& | 8147&&&&&&| 100.000 || /usr/bin/docker-containerd | 7115584&&&&&&&&| 1738&&&&&& | 1738&&&&&&| 100.000 || /etc/udev/hwdb.bin&&&&&&&& | 6711310&&&&&&&&| 1639&&&&&& | 1639&&&&&&| 100.000 |+----------------------------+----------------+------------+-----------+---------+
默认情况下会显示cache文件的全路径,会比较长。可以使用--bname选项来仅显示文件名。
$ hcache --top 3 --bname
+-------------------+----------------+------------+-----------+---------+
| Size (bytes)
| Percent |
|-------------------+----------------+------------+-----------+---------|
| 100.000 |
| docker-containerd | 7115584
| 100.000 |
| hwdb.bin
| 100.000 |
+-------------------+----------------+------------+-----------+---------+
$ hcache --top 3 --bname+-------------------+----------------+------------+-----------+---------+| Name&&&&&&&&&&&&&&| Size (bytes)&& | Pages&&&&&&| Cached&&&&| Percent ||-------------------+----------------+------------+-----------+---------|| dockerd&&&&&&&&&& | &&&&&& | 8147&&&&&& | 8147&&&&&&| 100.000 || docker-containerd | 7115584&&&&&&&&| 1738&&&&&& | 1738&&&&&&| 100.000 || hwdb.bin&&&&&&&&&&| 6711310&&&&&&&&| 1639&&&&&& | 1639&&&&&&| 100.000 |+-------------------+----------------+------------+-----------+---------+
查看指定进程的Cache使用情况。
$ hcache -pid 2903 -bname
$ hcache -pid 2903 -bname
另外还可使用指定格式输出,比如:JSON、纯文本。更多使用方法可参考hcache -h。
$ hcache -h
Usage of hcache:
convert paths to basename to narrow the output
print a simple histogram instead of raw data
return data in JSON format
omit the header from terse & text output
show all open maps for the given pid
return data with no box characters
include the per-page status in JSON output
show terse output
convert paths to basename to narrow the output
return data with unicode box characters
12345678910111213141516171819202122
$ hcache -hUsage of hcache:&&-bname&&&&&&&&convert paths to basename to narrow the output&&-histo&&&&&&&&print a simple histogram instead of raw data&&-json&&&&&&&&return data in JSON format&&-nohdr&&&&&&&&omit the header from terse & text output&&-pid int&&&&&&&&show all open maps for the given pid&&-plain&&&&&&&&return data with no box characters&&-pps&&&&&&&&include the per-page status in JSON output&&-terse&&&&&&&&show terse output&&-top int&&&&&&&&convert paths to basename to narrow the output&&-unicode&&&&&&&&return data with unicode box characters
如果您觉得本站对你有帮助,那么可以支付宝扫码捐助以帮助本站更好地发展,在此谢过。
or分享 (0)手动释放cache
# echo 3 & /proc/sys/vm/drop_caches
阅读(...) 评论()没有更多推荐了,
不良信息举报
举报内容:
swap区的作用,内存,cache,buff的区分
举报原因:
原文地址:
原因补充:
最多只允许输入30个字
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!没有更多推荐了,
不良信息举报
举报内容:
buff/cache 内容释放
举报原因:
原文地址:
原因补充:
最多只允许输入30个字
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!

我要回帖

更多关于 top buff cache 的文章

 

随机推荐