5.cgo 原理解析及优化实践## GCN ## cgo 原理解析及优化实践  朱德江 蚂蚁集团 MOSN 核心成员 Golang contributor Envoy Golang extension maintainer ## 0 公众号 • 开源爱好者  背景介绍 01 cgo 工作机制 02 cgo 调度机制 03 CPU 优化 04 GC 优化 05 ## 第一部分 背景介绍 ## 网关发展历史  ## Preparation: Driver - Metal as Example /* #cgo CFLAGS: -Werror -fmodules -x objective-c #cgo LDFLAGS: -framework Metal -framework CoreGraphics #include "mtl.h" */ Go when using GPUs Costs of Cgo o Fundamental infrastructure o Common abstraction o Writing and debugging shaders Conclusion and outlooks ## Challenge 1: The cost of Cgo Operations on GPU involves involves system calls, and easiest approach is to use Cgo: /* #cgo CFLAGS: -Werror -fmodules -x objective-c #cgo LDFLAGS: -framework Metal -framework CoreGraphics #include "mtl.h" */ import "C"0 码力 | 57 页 | 4.62 MB | 2 年前3
Go语言 - 一些简单的读书分享c2a2c9737d85a42790309bfa0aff5b7/p2_2.jpg) · 我是作者之一 - 这本书在写的时候国内的 Go 语言书很少 • 现在销量约 2w+ - 直到现在,CGO 和 plan9 汇编的内容依然是独一份 ## 目录 为什么要读书 01 带着问题读书 02 怎么样读书 03 应该读哪些书 04 ## 第一部分 为什么要读书 ## 为什么要读书 -0 码力 | 16 页 | 9.09 MB | 2 年前3
01. MOSN 高性能网络扩展实践 - 王发康GoLang Runtime 还未完全支持;不能复用已有的 SDK,需要做网络 IO 适配改造| |External-Proc Extension|跨语言支持、隔离性|需要跨进程通信性能低 (UDS vs CGO 1KB Latency 差 8 倍);需要扩展具备 gRPC server 能力,多进程管理复杂| |MOSN(GoLang) Extension|可复用 MOSN 现有的 filter 能力,改造成本低;研发效率高 contact here. 通过 CGO API 作为 Envoy 的 GoLang 扩展通道是不错的 IMHO, if we wanted to go out-of-process, something like ext_proc is desirable. If we want to stay in process, I think this CGO API is interesting 方案分析 ## CGO 是 Go 官方出品 golang.org/cmd/cgo/ ## Command cgo Using cgo with the go command Go references to C C references to Go Passing pointers Special cases Using cgo directly ## 社区 CGO 维护频度 Go0 码力 | 29 页 | 2.80 MB | 2 年前3
1.3 MOSN 在云原生的探索及实践云原生网络平台建设 • 升级 Xprotocol 框架 • 支持 WASM • 区块链网络框架 • 代码热更新 高性能网络层扩展 • fastGRPC • 协程收敛 epoll 模型 • CGO 性能优化 微服务 云原生 - 支持 zipkin,Jaeger 等 • 支持 ZK, Nacos 等 • 支持 Dubbo 3.0 - 支持 thrift, kafka 等协议 - 支持 还未完全支持;不能复用已有的 SDK,需要做网络 IO 适配改造| |External-Proc Extension|适合治理能力已经是一个远程服务,集成进 Envoy|需要跨进程通信性能低(UDS vs CGO 1KB Latency 差 8 倍);需要扩展具备 gRPC server 能力,多进程管理复杂| |MOSN(GoLang) Extension|可复用 MOSN 现有的 filter 能力,改 contact here. 通过 CGO API 作为 Envoy 的 GoLang 扩展通道是不错的 IMHO, if we wanted to go out-of-process, something like ext_proc is desirable. If we want to stay in process, I think this CGO API is interesting0 码力 | 36 页 | 35.61 MB | 2 年前3
2.6 Go in Linux Desktop EnvironmentDeepin XX ? ## 遇到的问题 • 与其他组件的融合 • X11 ## 解决方式 • using CGO to get anything • Pure golang library CGO Tips • Go-C C-Go • struct • array ## CGO Tips: Go call C functions && types convert package glue-C is far less than perl、python ... ## CGO Tips: Even more convenient than C at make time package main /* #cgo pkg-config: gtk+-3.0 #includevoid write_c_funct GTK_WINDOW_TOPLEVEL) C.write_c_function_in_go_source(w) C.gtk_widget_show_all(w) C.gtk_main() } ## CGO Tips: Struct is also easy to use package main /* #include#include struct tm* 0 码力 | 36 页 | 414.50 KB | 2 年前3
1.5 Badger_ Fast Key-Value DB in Goreplacement for Go map Motivation and Outcome Cgo is not Go Some people,when confronted with a problem,think “I know,I’ll use cgo.” Now they have two problems. ->Cgo is not Go, Dave Cheney RocksDB Great write Required Cgo. BoltDB Pure Go. Great read throughput. Cons: Bad write throughput. Why build it? Go native key-value DB for Dgraph. No compromise in read-write performance. Avoid Cgo. What workload. All your data can fit in memory easily. Use Badger if… You Go! You want to avoid Cgo. You want a performant read-write workload. You access data concurrently (many goroutines accessing0 码力 | 74 页 | 1.70 MB | 3 月前3
Golang Manual By AstaXie-20120522add to archive // Cgo directives CgoCFLAGS []string // cgo: flags for C compiler CgoLDFLAGS []string // cgo: flags for linker CgoPkgConfig []string // cgo: pkg-config names Gccgo is a GCC front-end that can, with care, be linked with GCC-compiled C or C++ programs. The cgo program provides the mechanism for a "foreign function interface" to allow safe calling of https://github.com/ziutek/mymysql - ODBC: https://bitbucket.org/miquella/mgodbc - Postgres (uses cgo): https://github.com/jbarham/gopgsqldriver - Postgres (pure Go): https://github.com/bmizerany/pq0 码力 | 6205 页 | 12.83 MB | 2 年前3
Golang 微服务在腾讯游戏用户运营领域的探索及实践(otto) Python/PHP cLua/cLuaJIT GopherLua • Expression、Learning cost • CGO overhead • Performance • CGO / Thread Safe • CGO / Thread overhead • Performance / API friendly ## 嵌入式Lua虚拟机 Gopherlua0 码力 | 34 页 | 1.22 MB | 2 年前3
Gitea v1.21.1 中文文档ARM64(GOOS=linux 和 GOARCH=arm64)进行交叉编译,您需要 aarch64-unknown-linux-gnu-gcc 交叉编译器。这是因为 Gitea 构建标签使用了 cgo 的外部函数接口(FFI)。 在没有任何标签的情况下,交叉编译的 Gitea 为 Linux ARM64 版本: 1. GOOS=linux GOARCH=arm64 make build 要交叉编译 编译 (Linux → Linux) 1. CC="zig cc -target x86_64-linux-gnu" \ 2. CGO_ENABLED=1 \ 3. CGO_CFLAGS=-O2 -g -pthread \ 4. CGO_LDFLAGS=-linkmode=external -v" 5. GOOS=linux \ 6. GOARCH=amd64 \ 7. TAGS="bindata build ## • 交叉编译(Linux → Windows) 1. CC="zig cc -target x86_64-windows-gnu" \ 2. CGO_ENABLED=1 \ 3. CGO_CFLAGS=-O2 -g -pthread \ 4. GOOS=windows \ 5. GOARCH=amd64 \ 6. TAGS="bindata sqlite0 码力 | 303 页 | 3.88 MB | 2 年前3
共 60 条
- 1
- 2
- 3
- 4
- 5
- 6













