tech
Go 的 Lambda 之争:一个提案争论了 8 年
一个提案,900 条评论,Go 核心团队亲自下场——这场争论终于要尘埃落定了吗?
tech
一个提案,900 条评论,Go 核心团队亲自下场——这场争论终于要尘埃落定了吗?
tech
最近,Go 语言社区围绕一个全新的内存管理提案展开了激烈讨论:在不依赖垃圾回收 (GC) 的情况下直接释放并重用内存。#74299 引入了 runtime.free 及相关机制,试图让编译器和标准库在特定场景下安全地跳过 GC,对短命的内存对象进行即时回收利用github.comgo.googlesource.com。此举被认为可能为 Go 带来一次性能上的革命:初步原型显示,在 strings.Builder 这样的场景中,利用该机制性能提升可达 2 倍github.com。本文将回顾 Go 内存管理领域从 arena 实验到 memory region 构想,再到 runtime.free 提案的探索之旅,并剖析这一新提案的技术细节、产生的意义、演化过程,以及对普通开发者的影响。 runtime.free 将在 Golang1.26
tech
Explore an in-depth analysis of Go's garbage collector, covering the evolution from concurrent mark-sweep to the groundbreaking Green Tea GC. Delve into key issues such as high concurrency bottlenecks, inefficient memory access, and CPU overhead, while discovering how per-span batch scanning and ad…
tech
本文深入解析 Go 语言垃圾回收(GC)机制的设计与不足,从并发标记-清除、内存局部性问题到高 CPU 占用,透彻剖析了 Go GC 在高并发、大内存场景下的挑战。文章重点介绍了最新的 Green Tea GC 优化方案——通过 span 批量扫描提升内存访问效率和多核扩展性,实现部分场景下 GC 耗时降低 35%,为极限性能优化和未来硬件加速提供了新思路。关键词包括 Go 垃圾回收优化、Green Tea GC、并发GC、高负载场景等。
tech
Discover the hidden pitfalls of gRPC, including inefficient protobuf code generation, language-specific quirks, and steep learning curves. This article dives into challenges like dependency management, subpar editor support, and documentation issues while highlighting community tools for microservi…
tech
Go 标准库提案:更优雅的 HTTP 内容协商 背景 在 Web 开发中,HTTP 内容协商(Content Negotiation)是一项重要的机制,它允许客户端和服务器就响应内容的最佳格式达成一致。例如,手机端可能希望接收 JSON 格式的数据,Web端可能想要XML格式的数据,服务端可以在一个接口中提供多种数据格式。客户端通过 Accept 请求头表达自己的偏好,服务端根据这些偏好选择最合适的格式返回。 具体内容可以参考RFC9110 比如在下面的例子中,使用Gin框架自己实现的内容协商 。在一个API接口中返回了JSON和XML两种格式。 package main import ( "net/http" "github.com/gin-gonic/gin" ) type User struct { Name string `json:"
tech
This article delves into the go:fix tool, its principles, applications, and usage examples for automated code migration.
tech
Go 1.24 引入了许多工具方面的重要更新,这些更新让开发者在管理依赖、调试问题以及编写更高质量代码时变得更加高效。尽管人们通常会将注意力集中在标准库或语言特性上的变化,但 Go 工具生态系统的改进同样值得关注。在本文中,我们将重点探讨两个关键领域的改进:go tool和vet工具,并通过实际示例展示这些更新如何优化你的工作流程。 Go 命令的增强功能 在 Go 1.24 中,go 命令进行了多项改进,使得依赖管理和工具执行更加高效且易于使用。其中最显著的变化之一是 go.mod 文件中新增了 tool 指令,允许你直接跟踪可执行工具依赖,而无需依赖诸如空导入等不直观的解决方案。 使用 Tool 指令跟踪可执行工具依赖 我们在项目中大量使用mockery[1](一个流行的 Mock 代码生成器),使用方式是通过brew 安装或者直接下载特定版本的exe 执行文件。但是这样有个问题,如果不同开发者使用的mockery 版本不一致,会造成非预期的代码冲突。在过去,如果您想将这样的工具作为项目的一部分,
tech
Explore the groundbreaking Swiss Map in Go 1.24, which offers over 50% performance improvement and seamless migration from legacy maps. Discover the benefits of Extensible Hashing and its innovative design while addressing challenges like concurrency and memory efficiency. Is it time to adopt Swiss…
tech
Go 1.24 introduces the `weak` package for managing memory more flexibly with weak pointers, preventing GC issues. Ideal for caching! 💻✨
tech
Weak 是什么? Golang 在1.24 中带来了一个新的std-lib weak。 可以为*T 创建一个安全的引用,但是不会阻止 *T 被GC 回收。 Package weak provides ways to safely reference memory weakly, that is, without preventing its reclamation. 跟 OS.ROOT 一样, weak 也是一个在其他语言中存在很久的功能,比如: * Java 的 WeakReference 和 SoftReference 是经典实现,主要用于缓存和对象池。它们能够在 JVM 检测到内存不足时自动回收。 * Python 提供了 weakref
tech
Introduction The previous article discussed two lock-free programming strategies: eliminating shared data and avoiding concurrent access to the same data through careful design. While achieving lock-free programming is ambitious, it could be more practical. Generally, when discussing lock-free techniques, the aim is to avoid locks, and using