tech
Go High-Performance Programming EP10: Two Useful Golang Lock-Free Programming Tips
Understanding the Essence of Lock-Free Programming
tech
Understanding the Essence of Lock-Free Programming
tech
对于无锁编程来讲,无锁只是一个表象,编程者设法组织 data+processing,重点在于如何消除 dataracing。而消除 dataracing 而言,传统的并发编程逻辑是采用关键区、排他性锁、读写锁等方式来保护 data 不会因为 processing 而导致错误读或错误写,那么对于无锁编程来说,则是通过消除 data 的共享性,或者消除并发操作 data 等方式来解决问题。 所以最典型的无锁编程技法包含两个技巧: 1. structure 2. bumper loop 其他的方法都是相似思路的具体衍生。 这里的“其他的方法”,是指完全不使用锁定或 CAS 的算法设计方案。本文中讨论的是如何设计数据结构及其处理器(算法)来防止加锁,甚至于连 CAS 也去除。 至于在共享的data上强行消除竞争读写问题的其他无锁方案,例如RingBuffer之类的工具类库,则是完全依赖于具体的 data 实体并在具体的 CPU 上进行设计,基本上是一种很受限的方法,
tech
Go 可能会引入 SwissTable 作为 map 的标准实现,以提高性能和内存效率!🚀 #Golang #SwissTable #编程
tech
Avoid memory leaks in Go by closing files and HTTP responses, managing goroutines properly, and using `defer` wisely. #GoLang #MemoryManagement
tech
限流机制在软件架构中至关重要,能够防止系统过载。文章分析了流量计数器、滑动窗口、漏桶和令牌桶四种限流算法,并探讨其优缺点。对于微服务架构,分布式限流和基于优先级的额度方案提升了用户体验。
tech
Exploring Rate Limiting Mechanisms to Maintain System Stability
tech
About the improvement of nil value
tech
探索encoding/json/v2中的空值处理改进,提升Go语言的灵活性与兼容性
tech
Recently, I discovered that the Go standard library includes a built-in implementation of varint, found in encoding/binary/varint.go. This implementation is similar to the varint used in protobuf. Using the Golang standard library's varint source code, we will systematically learn and review the concept of
tech
最近发现 Golang 标准库竟然自带了 varint 的实现,代码位置在 encoding/binary/varint.go,这个跟protobuf里面的varint实现基本是一致的。刚好借助 golang 标准库的 varint 源码,我们来系统地学习和梳理下 varint。 熟悉 protobuf 的人肯定对 varint 不陌生,protobuf 里面除了带 fix (如 fixed32、fixed64) 之外的整数类型, 都是 varint 编码。 varint 的出现主要是为了解决两个问题: 1. 空间效率:以 uint64 类型为例,可以表示的最大值为 18446744073709551615。然而在实际业务场景中,我们通常处理的整数值远小于 uint64 的最大值。假设在我们的业务中,需要处理的整数值仅为 1,但在网络传输过程中,
tech
Effective Usage and Common Pitfalls
tech
本文介绍了Go语言中的runtime.SetFinalizer函数,探讨了如何在对象被垃圾回收之前执行清理操作。通过示例代码,展示了SetFinalizer的用法及其潜在问题,如内存泄漏和对象生命周期延长。文章还提到在实际应用中,SetFinalizer的使用较少,但在Go源码中有广泛应用,提供了对资源管理的深刻见解。