Optimization for number of goroutines using feedback control# Optimization for number of goroutines using feedback control Yusuke MIYAKE / Pepabo R&D Institute, GMO Pepabo, Inc. 2019.07.25 GopherCon 2019  ## How many is the optimal number of goroutines? ## Performance tuning in case of pt  ## plan First steps ## Run to cursor Don't debug. Print! Attach to process Debug Goroutines Superpower! ## Try to be faster than debugger ## Shout the 'total' value! func sum(numbers0 码力 | 36 页 | 1.15 MB | 2 年前3
The Way To Go - 2012Tuning with pprof .....371 Chapter 14—Goroutines and Channels .....375 14.1 Concurrency, parallelism and goroutines .....375 14.1.1 What are goroutines? .....375 14.1.2 The difference between cores to be used on the command-line? .....379 14.1.5 Goroutines and coroutines .....381 14.2 Channels for communication between goroutines .....381 14.2.1 Concept .....381 14.2.2 Communication Communication operator <- .....383 14.2.3 Blocking of channels .....385 14.2.4 Goroutines synchronize through the exchange of data on one (or more) channel(s) .....387 14.2.5 Asynchronous channels—making0 码力 | 629 页 | 4.85 MB | 2 年前3
1.3 Go coding in go waykeywords one way to write a piece of code and minimize programmer’s effort garbage collection goroutines constants interfaces packages short naming thought 短小 一致 在上下文环境中用最短的名字携带足够的信息 类型间的耦合方式直接影响到程序的结构 Go语言通过“组合”方式构架程序结构 垂直组合(类型组合):type embedding 水平组合:通过interface“连接” 更大概念上的组合:goroutines和channels vertical composition thought vertical composition by type embedding 组合而不是继承,没有 concurrency是一种在程序执行层面上的组合:goroutines各自执行特定的工作,通过 channels+select将goroutines连接起来 适应现代计算环境 鼓励独立计算的分解 从某种意义上说,Go语言就是关于conconcurrency和interface的设计! 语言设计 goroutines提供并发执行,它是Go runtime调度的基本单元0 码力 | 69 页 | 1.24 MB | 1 月前3
Go 101 (Golang 101) v1.21.0Package Imports §11. Expressions, Statements and Simple Statements §12. Basic Control Flows §13. Goroutines, Deferred Function Calls and Panic/Recover ## • Go Type System o §14. Go Type System Overview programming support • goroutines (green threads) and start new goroutines easily. • channels (based on CSP model) and select mechanisms to do synchronizations between goroutines. • the container types either declared before or after any of its calls. Function calls can be deferred or invoked in new goroutines (green threads) in Go. Please read a later article ( $ §13 $ ) for details. ## Exiting (or Returning)0 码力 | 630 页 | 3.77 MB | 2 年前3
Go 101 (Golang 101) v1.21.0Package Imports ☐ §11. Expressions, Statements and Simple Statements §12. Basic Control Flows §13. Goroutines, Deferred Function Calls and Panic/Recover ## • Go Type System o §14. Go Type System Overview programming support • goroutines (green threads) and start new goroutines easily. ○ channels (based on CSP model) and select mechanisms to do synchronizations between goroutines. • the container types either declared before or after any of its calls. Function calls can be deferred or invoked in new goroutines (green threads) in Go. Please read a later article ( $ §13 $ ) for details. ## Exiting (or Returning)0 码力 | 610 页 | 945.17 KB | 2 年前3
Go 101 (Golang 101) v1.21.0Package Imports §11. Expressions, Statements and Simple Statements §12. Basic Control Flows §13. Goroutines, Deferred Function Calls and Panic/Recover ## • Go Type System o §14. Go Type System Overview programming support • goroutines (green threads) and start new goroutines easily. • channels (based on CSP model) and select mechanisms to do synchronizations between goroutines. • the container types either declared before or after any of its calls. Function calls can be deferred or invoked in new goroutines (green threads) in Go. Please read a later article ( $ §13 $ ) for details. ## Exiting (or Returning)0 码力 | 880 页 | 833.34 KB | 2 年前3
主从监控项经验分享494698484 go_gc_duration_seconds_count 240076 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 8 # HELP go_info Information about the Go environment 494698484 go_gc_duration_seconds_count 240076 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 8 # HELP go_info Information about the Go environment 29.074967638 go_gc_duration_seconds_count 245704 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge 监控项类型:http url:http://127.0.0.1:9100/metrics 数据类型:文本/text0 码力 | 26 页 | 3.92 MB | 2 年前3
Golang Manual By AstaXie-20120522Processes (CSP), it can also be seen as a type-safe generalization of Unix pipes. ## Goroutines They're called goroutines because the existing terms—threads, coroutines, processes, and so on—convey inaccurate connotations. A goroutine has a simple model: it is a function executing concurrently with other goroutines in the same address space. It is lightweight, costing little more than the allocation of stack start small, so they are cheap, and grow by allocating (and freeing) heap storage as required. Goroutines are multiplexed onto multiple OS threads so if one should block, such as while waiting for I/O0 码力 | 6205 页 | 12.83 MB | 2 年前3
Real World GoGo analogue: goroutines connected by channels. ## Concurrency: goroutines Goroutines are like threads: • They share memory. But cheaper: • Smaller, segmented stacks. • Many goroutines per operating Look back at the sort example - how to tell when it's done? Use a channel to synchronize goroutines: done := make(chan bool) doSort := func(s []int) { sort(s) done <- true } i := pivot(s) process(task) } } 3 Google Confidential ## Concurrency: communication A Go idiom: many worker goroutines receive tasks from a channel. type Task struct { // some state } func worker(in, out chan *Task)0 码力 | 49 页 | 595.19 KB | 2 年前3
共 86 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9













