惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
K
Kaspersky official blog
Microsoft Azure Blog
Microsoft Azure Blog
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
G
GRAHAM CLULEY
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
I
Intezer
D
Docker
月光博客
月光博客
L
Lohrmann on Cybersecurity
Latest news
Latest news
B
Blog
罗磊的独立博客
M
MIT News - Artificial intelligence
S
Securelist
Know Your Adversary
Know Your Adversary
Help Net Security
Help Net Security
Recorded Future
Recorded Future
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
T
Threatpost
H
Hacker News: Front Page
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
人人都是产品经理
人人都是产品经理
F
Fortinet All Blogs
博客园 - Franky
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
A
About on SuperTechFans
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tor Project blog
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Engineering at Meta
Engineering at Meta
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Microsoft Security Blog
Microsoft Security Blog

K.I.S.S

身在 Kimi 的 800 天 写在 Kimi K2 发布之后:再也不仅仅是 ChatBot macOS 按域名切换 DNS 解析 | K.I.S.S 为什么说 GPT 是无损压缩 | K.I.S.S 握着你的手训一个类GPT语言模型 (二) | K.I.S.S 握着你的手训一个类GPT语言模型 (一) | K.I.S.S Rosetta in Linux Virtual Machine on Apple Silicon Fit an Overfit with MegEngine 把 CUPS 扔进 docker 里 ASUS Chromebook Flip | K.I.S.S GPG 与 SSH Agent 转发 使用 dnsmasq 和 ipset 的策略路由 YubiKey 4 简介与配置 | K.I.S.S 定制GH60机械键盘 | K.I.S.S Debian 网络安装内核参数 | K.I.S.S 我的 Vim 配置 | K.I.S.S Libinput 与 Udev | K.I.S.S 给妹子看的 Arch Linux 桌面日常安装 | K.I.S.S 修复GTK3 CSD外观 | K.I.S.S 握着你的手教你画哀女王 | K.I.S.S R.I.P Google Reader | K.I.S.S Richard Stallman仍然是对的 | K.I.S.S Scala 自定义控制结构 | K.I.S.S 入手Wacom Bamboo CTL470 | K.I.S.S 转个型? | K.I.S.S Wish List | K.I.S.S pulseaudio音量问题 | K.I.S.S 入手yubikey,一点小心得 | K.I.S.S 迁移到Octopress | K.I.S.S 自动更新DNSPod记录 | K.I.S.S Linux 用作 IPv6 网关 | K.I.S.S Conky从豆瓣获取MPD专辑封面 | K.I.S.S 我和Linus大学时那些事儿 | K.I.S.S Micro$oft依然是那副老德行 | K.I.S.S 用PulseAudio TCP Forwarding实现网络传声 | K.I.S.S 新的短网址 | K.I.S.S 紧张的一个月 | K.I.S.S 5月11日活动有感 | K.I.S.S 西电开源社区2011年Tee 最终版 | K.I.S.S 多头多尾的Linux | K.I.S.S Linux的中文名称怎么翻译呢? | K.I.S.S iPhone使用OpenVPN | K.I.S.S 我的人人网敏感词 | K.I.S.S 纪念钱立生老师 | K.I.S.S twitter键盘控:Twittperator | K.I.S.S 天生的暴力倾向? | K.I.S.S The Open Source Spirit | K.I.S.S Libreoffice | K.I.S.S Hello world! | K.I.S.S Python 调用gnuplot的例子 | K.I.S.S The Beginning | K.I.S.S About Me | K.I.S.S
利用tmpfs加速gnome-shell overview模式Applications索引 | K.I.S.S
2011-07-29 · via K.I.S.S

gnome-shell的overview模式着实是个尤物,动态工作区和任务管理丝毫不输于Lion的Mission Control,而Applications与Lion的LaunchPad也是异曲同工。

然而有一点不爽,每次加载Applications都很慢,而且硬盘狂转,搞的这个很美丽的功能几乎不被使用。有必要加速一下。

考虑到速度瓶颈主要是磁盘读取 /* 对MBA的SSD表示羡慕嫉妒恨 */ ,想到如果能预先把Applications里的内容缓存到内存里就好了,Applications里其实是加载了/usr/share/applications里的文件,于是想到了把/usr/share/applications 挂载为 tmpfs 。 //总共不过[0-9]M的文件,这点内存咱还是有的

mkdir -p /tmp/app_temp
cp -aR /usr/share/applications/* /tmp/app_temp #先把文件备份出来
mount -t tmpfs none /usr/share/applications
cp -aR /tmp/app_temp/* /usr/share/applications

现在试试,速度是不是快多了?

用tmpfs虽然速度快了,但只要一关机,所有数据就都丢失啦!//就好像车头被掩埋了一样~

解决办法也很简单,在合适的时候把内容拷贝回硬盘,每次开机时再拷贝回去就是。

对于“合适的时候”,笨一点的方法可以是用crond周期同步一下,本人用一种聪明点的办法 —- 利用 inotify .

Inotify一种强大的、细粒度的、异步文件系统监控机制,它满足各种各样的文件监控需要,可以监控文件系统的访问属性、读写属性、权限属性、删除创建 移动等操作。

也就是说,利用inotify监控/usr/share/applications目录,一旦发生变化,就想磁盘中同步数据,每次开机时从磁盘中恢复即可。生产环境中常用inotify+rsync实现实时同步,不过这种小hack要用rsync实在让我不爽,直接cp和rm得了。

#!/bin/bash
MEM_DIR="/usr/share/applications"
HD_DIR="/var/lib/app_db"
cp -aR ${HD_DIR}/* ${MEM_DIR}/
inotifywait -mrq --format '%e%%%f' \
   -e modify,delete,move,create ${MEM_DIR} \
  |while read raw_data
do
	DO=`echo $raw_data|cut -d% -f1`
	FILE=`echo $raw_data|cut -d% -f2`
	case "$DO" in
	  CREATE|MOVED_TO|MODIFY)
		cp ${MEM_DIR}/${FILE} ${HD_DIR}/
		;;
	  DELETE|MOVED_FROM)
		rm ${HD_DIR}/${FILE}
		;;
	esac
done

把这段脚本存为 sync_tmpfs.sh ,加入 /etc/rc.loal 中,使之开机自动运行:

(bash /path/to/script/sync_tmpfs.sh ) &

再修改一下fstab

tmpfs /usr/share/applications tmpfs defaults,mode=0755 0 0

重启一下,大功告成~