golang-mysql包

golang原生的mysql包是https://github.com/go-sql-driver/mysql

其中DSN (Data Source Name)格式username:password@protocol(address)/dbname?param=value

字段介绍
username数据库账号名
password数据库密码
protocol协议,tcp,
address数据库host地址
dbname数据库名,此项为可选项
param参数支持多个,且区分大小写
参数默认介绍
allowAllFilesfalse
allowCleartextPasswordsfalse
allowNativePasswordstrue
allowOldPasswordsfalse
charset常用,字符集
checkConnLivenesstrue
collationutf8mb4_general_ci
clientFoundRowsfalse
columnsWithAliasfalse
interpolateParamsfalse
locUTC常用,时区
maxAllowedPacket4194304
multiStatementsfalse
parseTimefalse
readTimeout0执行读开始计算时间,超过则中断
rejectReadOnlyfalse
serverPubKeynone
timeoutOS default
tlsfalse
writeTimeout0

其他参数的填写则设置为系统变量,string要用单引号圈起来且url.QueryEscape处理

Scalable Go Scheduler Design Doc 中文翻译

原文链接:https://golang.org/s/go11sched

以下是原文


Scalable Go Scheduler Design Doc

该文档假定您对Go 语言 和当前的 goroutine 调度程序实现有一定的了解。

当前调度程序的问题

当前的 goroutine 调度器限制了用 Go 编写的并发程序的可扩展性,特别是高吞吐量服务器和并行计算程序。 Vtocc 服务器在 8 核机器上最多可使用 70% 的 CPU,而性能分析显示 14% 用于runtime.futex(). 通常,调度程序可能会禁止用户在性能至关重要的情况下使用惯用的细粒度并发。

当前实现有什么问题:

  1. 单一全局互斥锁(Sched.Lock)和集中状态。互斥锁保护所有与 goroutine 相关的操作(创建、完成、重新调度等)。

  2. Goroutine (G) 切换 (G.nextg)。工作线程 (M’s) 经常在彼此之间切换可运行的 goroutine,这可能会导致延迟增加和额外开销。每个 M 必须能够执行任何可运行的 G,尤其是刚刚创建 G 的 M。

  3. 每个M内存缓存(M.mcache)。内存缓存和其他缓存(堆栈分配)与所有 M 相关联,而它们只需要与 M 正在运行的 Go 代码相关联(在 syscall 内部阻塞的 M 不需要 mcache)。运行的 Go 代码的M 与所有 M 之间的比率可以高达 1:100。这会导致过多的资源消耗(每个 MCache 最多可吸收 2M)和较差的数据局部性。

go源码编译

学习go的源码编译

下载源码仓库

git clone git@github.com:golang/go.git

我选择了其中一个分支 release-branch.go1.18

git checkout release-branch.go1.18

目录结构

$ tree -d -L 2
.
├── api
├── bin
├── doc
├── lib
│   └── time
├── misc
│   ├── android
│   ├── arm
│   ├── cgo
│   ├── chrome
│   ├── ios
│   ├── linkcheck
│   ├── reboot
│   ├── swig
│   ├── trace
│   └── wasm
├── pkg
│   ├── darwin_arm64
│   ├── include
│   ├── obj
│   └── tool
├── src
│   ├── archive
│   ├── bufio
│   ├── builtin
│   ├── bytes
│   ├── cmd
│   ├── compress
│   ├── container
│   ├── context
│   ├── crypto
│   ├── database
│   ├── debug
│   ├── embed
│   ├── encoding
│   ├── errors
│   ├── expvar
│   ├── flag
│   ├── fmt
│   ├── go
│   ├── hash
│   ├── html
│   ├── image
│   ├── index
│   ├── internal
│   ├── io
│   ├── log
│   ├── math
│   ├── mime
│   ├── net
│   ├── os
│   ├── path
│   ├── plugin
│   ├── reflect
│   ├── regexp
│   ├── runtime
│   ├── sort
│   ├── strconv
│   ├── strings
│   ├── sync
│   ├── syscall
│   ├── testdata
│   ├── testing
│   ├── text
│   ├── time
│   ├── unicode
│   ├── unsafe
│   └── vendor
└── test
    ├── abi
    ├── alias3.dir
    ├── asmhdr.dir
    ├── bench
    ├── chan
    ├── closure3.dir
    ├── closure5.dir
    ├── codegen
    ├── ddd2.dir
    ├── dwarf
    ├── fixedbugs
    ├── import2.dir
    ├── import4.dir
    ├── interface
    ├── intrinsic.dir
    ├── ken
    ├── linkname.dir
    ├── method4.dir
    ├── oldescape_linkname.dir
    ├── retjmp.dir
    ├── runtime
    ├── stress
    ├── syntax
    ├── typeparam
    └── uintptrescapes.dir

94 directories

假设我要编译src/cmd/trace这个pkg

创建自己的github博客

初始化

准备工作

/images/121659584048_.pic.jpg

work flow

/images/111659582758_.pic.jpg

配置主题

选择 LoveIt主题 https://github.com/dillonzq/LoveIt

文档 https://hugoloveit.com/zh-cn/theme-documentation-basics/

代码来源 https://github.com/kasuganosoras/logo-maker

配置网站Favicon

将favicon_io.zip 文件解压到 ./static/下

配置 config.toml

[params.header.title]
logo = "/images/your logo.png"

logo的真实位置在 ./static/images/your logo.png

YouTube Logo

YouTube Logo

自定义你的 YouTube 风格 Logo