https://www.bmpi.dev/dev/deep-in-program-language/how-to-implement-concurrency/concurrency-model/ 编程语言是如何实现并发的之并发模型篇
相比CSP模型,Actor模型可以跨节点在分布式集群中运行: 存在信箱满后消息丢失的问题
Python
- Python Project Structure
- Google Python Style Guide
- PEP 8 -- Style Guide for Python Code
- https://buckbuild.com/function/glob.html
Go
- Goroutines
- GOMAXPROCS: # of operating system threads = # of logical processors
- Thousands of goroutines are bound to maybe 1 single processor
- Contention is low: Goroutines are currently partially preemptive (before Go1.9)
- Switch cost is low: modern scheduler is O(1) ~ O(logN), only 3 registers
- Concurrency: run at the same time
- Parallelism: threads run on different processors
- has little to do with CPU-bound test
- help a lot with non-CPU-bound test
- go test
- go test -cpu 4: set GOMAXPROCS to 4 (affects preemptive contentions)
- b.SetParallelism(p): sets the number of goroutines used by RunParallel to p*GOMAXPROCS
- go test -parallel n: maximum n tests to run simultaneously
- Context
- idiomatic go
- GOMAXPROCS: # of operating system threads = # of logical processors
- Thousands of goroutines are bound to maybe 1 single processor
- Contention is low: Goroutines are currently partially preemptive (before Go1.9)
- Switch cost is low: modern scheduler is O(1) ~ O(logN), only 3 registers
- has little to do with CPU-bound test
- help a lot with non-CPU-bound test
- go test -cpu 4: set GOMAXPROCS to 4 (affects preemptive contentions)
- b.SetParallelism(p): sets the number of goroutines used by RunParallel to p*GOMAXPROCS
- go test -parallel n: maximum n tests to run simultaneously
Coding
Why recursion is heavy? Stack frames may be too many which contains call's return address, local data, and parameters
算法
- https://en.wikipedia.org/wiki/Sorting_algorithm#Comparison_sorts
- QuickSort: O(logn) < O(Space) < O(n). Worst case: 基本有序, Partition value can only order one element at a time O(Time) = O(n*n)
- partition(): move pivotIndex to the a[right]
- MergeSort: O(Space) = O(n): new queue for merging
- HeapSort: heapify(); siftdown(a, start, end)
- remove node: a[0], move a[-1] to the top, then siftdown()
- add node: a[-1], then siftup()
- heapify: siftup() 从前到后; siftdown() 从后到前
- 计算机科学中最重要的32个算法
- 《编程之法:面试和算法心得》
- 刘未鹏: 知其所以然(三):为什么算法这么难?
- leetcode题解
- Design Pattern