主题的晦涩 人生的短暂

kongjun18's Github chart

【译】无锁算法导论

译者序 An introduction to lockless algorithms是 Paolo Bonzini 在 LWN.net 上发布的无锁编程系列文章的第一篇,清楚明了地阐述了内存模型中的 acquire/release 语义。 当传统的锁定原语(locking primitives)无法使用或性能不足时,无锁算法就会引起 Linux 内核的兴趣。因此,无锁算法时不时出现在 LWN 上。LWN 最近一次提及无锁算法是在七月,这促使我写下了这一系列文章。更频繁出现的话题是 read-copy-upd

使用 yadm 管理点文件

When you live in a command line, configurations are a deeply personal thing. They are often crafted over years of experience, battles lost, lessons learned, advice followed, and ingenuity rewarded. When you are away from your own configurations, you are an orphaned refugee in unfamiliar and hostile surroundings. You feel clumsy and out of sorts. You are filled with a sense of longing to be back in a place you know. A place you built. A place where all the short-cuts have been worn bare by your own travels. A place you proudly call… $HOME. -- yadm website 点文件管理的痛点 管理点文件主要有两个目的: 方便拷贝配置到新机器 方便地查看对配置的更改 对于软件项目,Git 结合 Github 可以很好的满足这两点需求。但点文件不像软件代码

致敬经典:K&R allocator 内存分配器

k&R allocator 是Brain Kernighan和 Dennis Ritchie 的名著 The C Programming Language 第 8.7 节中介绍的一个简单 malloc 实现。因为该书被称为 K&R C,这个 malloc 实现也被称为 K&C allocator。 K&R allocator 的实现非常简洁,Linux 内核基于 K&R allocator 实现了用于嵌入式系统 slob allocator。见 slob: introduce the SLOB allocator,邮件摘要如下: SLOB is a traditional K&R/UNIX allocator with a SLAB emulation layer, similar to the original Linux kmalloc allocator that SLAB replaced. It's signicantly smaller code and is more memory efficient. But like all similar allocators, it scales poorly and suffers from fragmentation more than

深入剖析 Go 语言运行时:IO 轮询器

netpoller 概述 考虑一个基于 goroutine-per-connection 模型的 TCP echo server: import ( "fmt" "io" "log" "net" ) func worker(conn net.Conn) { defer conn.Close() b := make([]byte, 512) for { size, err := conn.Read(b) if err == io.EOF { break } if err != nil { log.Fatal(err) } size, err = conn.Write(b[0:size]) if err != nil { log.Fatal(err) } } } func main() { listner, err := net.Listen("tcp", "127.0.0.1:8080") if err != nil { log.Fatal(err) } for { conn, err := listner.Accept() if err != nil { log.Fatal(err) } go worker(conn) } }从用户侧看,系统该调用阻塞 goroutine,Go scheduler 调度其他 goroutine。问题在于,goroutine 复用在线程上,如果 IO 系统调用(如read(2

【译】内存屏障:软件黑客的硬件视角

译者序 Memory Barriers: a Hardware View for Software Hackers 是并发编程专家 Paul E. McKenney 的经典论文,该论文同时收录在他的著作 Is Parallel Programming Hard, And, If So, What Can You Do About It? 附录 C Why Memory Barriers? 中。 本文全文翻译该论文。 为什么中了邪的 CPU 设计者要让可怜的一无所知的软件设计者受内存屏障(memory barrier)的伤害? 简单地说,因为乱序内存引用可以带来更好的性能,所以需要用内存屏障在同步原语这类其正确操作依赖于排序的内存引用的东西中强制

【译】Go 语言数据竞争检测器

简介 数据竞争是并发程序中最普遍和最难调试的 bug。当两个 goroutine 并发访问同一变量且至少一个访问是写时发生数据竞争。更多细节参考 The Go Memory Model。 译者注 The Go Memory Model 可以参考我的博客 【译】Go 语言内存模型:2022-06-06 版。 这有一个可以导致程序崩溃(crashes)和内存损坏(memory corruption)的数据竞争的例子: xian sxian sfunc main() { c := make(chan bool) m := make(map[string]string) go func() { m["1"] = "a" //
0%