包含标签 linux 的文章

epoll

epoll epoll是一种I/O事件通知机制,是linux内核实现IO多路复用的一种方式。select和poll属于轮询机制。 假设有大量的请求和一个进程保持着TCP连接,但是其中只有一小部分是活跃的,这需要监听这些连接,在需要的时候返回,从而对其进行读写操作。 https://www.jianshu.com/p/31cdfd6f5a48……

阅读全文

runtime

goroutine M:N模型 go创建M个线程,之后创建个N个goroutine会依附在M个线程上执行。 pstree 命令看进程下几个线程 同一时刻,一个线程只能跑一个goroutine,当goroutine发生阻塞(chan阻塞,mutex,syscall陷入内核)时,go的runtime会进行调度,让其他g……

阅读全文

虚拟内存

mmap: 在进程的虚拟内存地址空间中分配地址,创建和物理内存之间的映射关系。mmap在虚拟内存中分配空间,只有在第一次使用虚拟内存的时候才分配物理内存。 mmap的write: 1. 用户态将需要写入的数据直接拷贝到mmap的地址 2. 若mmap地址未对应物理地址,缺页异常,由内核处理 3. 若对……

阅读全文

Haystack 图片存储系统

主要核心是减少硬盘操作 After reducing directory sizes to hundreds of images per directory, the resulting system would still generally incur 3 disk operations to fetch an image: one to read the directory metadata into memory, a second to load the inode into memory, and a third to read the file contents.……

阅读全文