学习
容器下的 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 进行

源码分析 Kubernetes 对 Pod IP 的管理
· ☕ 9 分钟
1. kube-controller-manager 对网段的管理 在 kube-controller-manager 有众多控制器,与 Pod IP 相关的是 NodeIpamController。 NodeIpamController 控制器主要是管理节点的 podcidr,当有新节点加入集群时,分配一个子网段给节点;当节点删除时,回收子网段。 每个节点的子网段不会重叠,每个节点都能够独立

FFmpeg 使用简易教程
· ☕ 2 分钟
1. 安装 FFmpeg macOS 上执行命令: 1 brew install ffmpeg 2. FFmpeg 使用 1 ffmpeg {1} {2} -i {3} {4} {5} 五个部分的参数依次如下: 全局参数,-y、-loglevel、-preset 等用来控制的整体行为 输入文件参数,-i、-ss、-t、-stream_loop 等用来控制输入文件的读入方式 输入文

一些程序构建的优化技巧
· ☕ 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” 移除调试信息,减小

Transformer 学习笔记
· ☕ 4 分钟
1. 为什么是 Transformer 全连接的自注意 以往的 RNN 模型,每个单词只能和邻近的单词产生联系,而 Transformer 模型中的 Attention 机制,单词可以和任意位置的单词产生联系,这样就可以捕捉到全局的上下文信息。 没有梯度消失问题 RNN 作用在同一个权值矩阵上,使得其最大的特征值小于 1 时,就会出现