研发
容器下的 Go 应用程序优化
· ☕ 2 分钟
1. 内存对齐 结构体内字段,从大到小排列 减少内存占用 安装 fieldalignment 工具 1 go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest 分析并修复内存对齐 1 2 3 4 5 6 7 8 9 fieldalignment -fix ./... /Users/shaowenchen/Code/app/config/config.go:136:14: struct with 32 pointer bytes could be 24 /Users/shaowenchen/Code/app/config/config.go:150:11: struct of size 96 could be 88 /Users/shaowenchen/Code/app/config/config.go:166:14: struct of size 152 could be 144 /Users/shaowenchen/Code/app/config/config.go:194:12: struct with 80 pointer bytes could be 72 /Users/shaowenchen/Code/app/config/config.go:209:12: struct with 56 pointer bytes could be 40 /Users/shaowenchen/Code/app/dao/gormx/gorm.go:12:13: struct with 16 pointer bytes could be 8 /Users/shaowenchen/Code/app/dao/gormx/entity/cluster.go:5:14: struct with 128 pointer bytes could be 104 查看 fieldalignment 进行

一些程序构建的优化技巧
· ☕ 2 分钟
持续更新中… 1. Golang 使用 trimpath 移除编译路径,避免暴露编译路径信息 1 go build -gcflags="all=-trimpath=${PWD}" -asmflags="all=-trimpath=${PWD}" -o ./bin/opscli ./cmd/cli/main.go 添加之前异常输出路径 /Users/shaowenchen/Code/Github/ops/main.go,添加之后异常输出路径 main.go 。 -ldflags “-w -s” 移除调试信息,减小

HuggingFace 的模型和数据操作
· ☕ 3 分钟
HuggingFace 通过提供共享模型 model、数据集 dataset、在线托管 space 等服务,为 AI 研究人员和开发者提供了一个完整的生态。本篇文章将介绍如何使用 HuggingFace 的模型和数据集。 1. 模型操作与使用 1.1 自定义存储目录 1 export HF_HOME=/Volumes/Data/HuggingFace 否则默认在 ~/.cache/huggingface 目录下。 1.2 模型的下载 第一种方法,页面上

使用 OpenAI 和 Langchain 通过对话直接调用函数
· ☕ 5 分钟
1. 大模型与 Langchain 很多人可能没有机会训练、甚至微调大模型,但对大模型的使用却是未来趋势。那么,我们应该如何拥抱这一变化呢?答案就是 Langchain。 大模型提供的是一种泛而通用的基础能力,目前,我看到的有两种主要落地方式: 基于生成能力的 AIGC,

GitHub Copilot Chat 使用
· ☕ 2 分钟
1. 申请使用 GitHub Copilot Chat 申请链接 https://github.com/github-copilot/chat_waitlist_signup/join 申请通过之后,会收到一封邮件: 2. 什么是 VS Code insiders 什么是 VS Code insiders VS Code insiders 是 VS Code 的预览版本,提供一些最新的功能和改进,更新非常频繁。如果有更新强迫症,慎重使用,因为几乎每天都有更新。 VS Code 和 VS Code insiders 的区别 VS Code 的命令行是 code ,logo