profile
viewpoint
Draven draveness @kubernetes Beijing, China https://draveness.me/ Go / Rails / Rust

draveness/analyze 7539

Draven's Blog

draveness/DKNightVersion 3506

Manage Colors, Integrate Night/Multiple Themes. (Unmaintained)

draveness/DKChainableAnimationKit 1911

A DSL to make animation easy on iOS with Swift.

draveness/ATProperty 144

:sunny: Create @property with shortcut

draveness/go-internal 95

《Go 语言设计与实现》示例代码

draveness/linux-archive 71

Linux archive for studying the process scheduler. 调度系统设计精要 http://draveness.me/system-design-scheduler

draveness/blog-comments 69

面向信仰编程

draveness/JSONCop 32

A better way to deal with JSON parsing in Swift.

draveness/ChainableKit 27

Chainable UIKit in Objective-C

draveness/Mineral 27

A library used to separate concerns from the original UIKit framework.

pull request commentkubernetes/kubernetes

style: update comments in topology manager

/retest

draveness

comment created time in 17 hours

issue commentdraveness/blog-comments

浅析 Bigtable 和 LevelDB 的实现 · /bigtable-leveldb

你好~文章写得非常清晰!获益良多! 想问下“多层级的 SSTable”部分,第二张图中,4个sstable是否应该是“level0”而不是“level1”呢?

感觉差不太多,这里就不改了

draveness

comment created time in 18 hours

pull request commentkubernetes/kubernetes

style: update comments in topology manager

/assign @klueska

draveness

comment created time in 18 hours

PR opened kubernetes/kubernetes

style: update comments in topology manager

/kind cleanup /sig node

NONE
+9 -9

0 comment

1 changed file

pr created time in 18 hours

create barnchdraveness/kubernetes

branch : feature/topology-manager-format

created branch time in 18 hours

push eventdraveness/kubernetes

lixiaobing1

commit sha bd17ef4f767a21868edafa19d7596e8df914b2db

fix func name NewCreateCreateDeploymentOptions

view details

bjrara

commit sha 87e775e066d58913efaeb86b2423fd90eca9fe0b

Enhance apiextensions-apiserver in standalone mode

view details

marload

commit sha 429672037c6eb2b871961ad0ba73521cd2ccb317

Refactoring: Reduce unnecessary lines

view details

Mike Spreitzer

commit sha ced8d9597587c4ebf64f82305f5002bc39eefcf4

Fix description of conversion generator The old description failed to note that the Convert_<pkg1>_<type>_To_<pkg2>_<type> function is NOT generated if generation of the corresponding autoConvert_... function ran into trouble with a missing or mis-typed field.

view details

Anish Shah

commit sha 0ffe89ed0b06a1355afe0a35e495aca3e6545b19

kubelet: add operations count and error count metrics to network plugin manager

view details

Gaurav Singh

commit sha 339ed92ba8393e9d4f276c039a0269b241e765f8

[e2e/storage] fix range issue in getCSINodeLimits Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

view details

SataQiu

commit sha 9c163f0a0a97a9bcf10c3f91d2cee02567700d84

kubectl: improve the warning message when doing kubectl apply to the resource without expected annotation Signed-off-by: SataQiu <1527062125@qq.com>

view details

hasheddan

commit sha 8accd354b04f549077ae85462a8f120e172f0ef8

Run make verify with python3 to fix publishing bot issue verify-publishing-bot is experiencing errors importing pyyaml since python3 was added to kubekins-e2e image. This changes make verify to run verify-publishing-bot with python3. Signed-off-by: hasheddan <georgedanielmangum@gmail.com>

view details

Shingo Omura

commit sha ef1fab76421a1c3b832ef728a66c331a81d1ec18

expose Run[Pre]ScorePlugins functions in PluginRunner interface

view details

Shingo Omura

commit sha d0421fa9c3eb64b12db1cd6ae8cd353e08a09ed4

Fix TestScorePlugin: numScore should be accessed with atomic.LoadInt32

view details

yodarshafrir1

commit sha ca420ddadaeae0a105c7dc83960e42db347ea598

Fix job's backoff limit for restart policy Never, rely on number of failures instead of number of NumRequeues

view details

yodarshafrir1

commit sha 24010022ef53f58455a32a5e081eabc2943092fa

Number of failed jobs should exceed the backoff limit and not big equal. Remove patch in e2e test of backoff limit due to usage of NumRequeues

view details

jay vyas

commit sha 1693c111bee20e51e5f535f07dddd9f5539dad23

Getting rid of the Salt DNS replacements, addded / back.

view details

Antonio Ojea

commit sha b0dfe256f54afc0ce717f57c8e82c2f9878f6ff6

remove iperf e2e test ip family tags

view details

Joakim Roubert

commit sha e773c5d19bdb544bed606ee1018baf363112ca34

Fix some shellcheck warnings/errors in cluster/gce/util.sh This patch removes superfluous use of cat. Signed-off-by: Joakim Roubert <joakim.roubert@axis.com>

view details

Ma Xinjian

commit sha a451e2ec3d248879d7c91d683ac8fa67484c65a7

Fix typo in comment of hack/verify-shellcheck.sh Signed-off-by: Ma Xinjian <maxj.fnst@cn.fujitsu.com>

view details

Lee Verberne

commit sha bf0a33d1de4cff08f527c29ab235ea85def3e197

Use EphemeralContainers for storage validation When updating ephemeral containers, convert Pod to EphemeralContainers in storage validation. This resolves a bug where admission webhook validation fails for ephemeral container updates because the webhook client cannot perform the conversion. Also enable the EphemeralContainers feature gate for the admission control integration test, which would have caught this bug.

view details

jay vyas

commit sha c6a4a87ff22ce049265fb2c5e4704296630aa0b0

pillar_dns_server remove change so as not to break tooling in the near term in the kubernetes/dns repo

view details

Chao Xu

commit sha 00a3db0063ff85d6fca9a83453a56eb98fc43521

Add the storageversion.Manager interface The interface exposes methods to record storage versions in ResourceInfo, to update StorageVersions, and to check if storageVersion updated have completed.

view details

Lion-Wei

commit sha dbb5438b330fd31de7d8321af5e022959819484e

fix kube-proxy cleanup

view details

push time in 18 hours

push eventdraveness/enhancements

Draven

commit sha 02f889bbc5c6c33a9d2ed3b973ce4307d5514bb1

doc: add diff before the code block in topology manager KEP

view details

push time in 19 hours

issue commentgolangci/golangci-lint

Private linters must be explicitly enabled in .golangci.yml to make effect

I met the same problem with 1.31.0 master branch, enable-all:true does not work at all. We need to enable them explicitly

chenlujjj

comment created time in 20 hours

issue commentdraveness/blog-comments

NVMe 固态硬盘与键值存储 KVell · SOSP 2019 - 面向信仰编程 · /papers-kvell

数据库优化器是不是慢慢就没啥用了

那倒不会...

draveness

comment created time in 2 days

issue commentdraveness/blog-comments

理解 Golang 哈希表 Map 的原理 · /golang-hashmap

想请教博主个问题。 slice虽然说是引用类型,但是如果slice作为函数入参,在函数里append入参的slice,即便是把append结果再赋值给入参,函数外面的slice是不受变化的。。那map如果作为入参,会不会也有类似的情况呢?

这个应该很好测试,你可以试一下

您好,我有一些问题想请教一下。

3.2.2的图HMAP & BUCKETS是不是有些问题,应该是extra.nextoverflow字段指向空闲的溢出桶,而非extra.overflow字段。

我在源码中发现hmap中extra.nextOverflow是指向未使用的溢出桶的首地址的,而通过extra结构中注释代码发现extra.overflow字段只记录当前使用过的溢出桶,extra.oldoverflow字段是旧桶的overflow结构,这两个字段只有当key和elem的类型都不包含指针时使用,作用是防止溢出桶被GC,

后面会 Review 这个问题

draveness

comment created time in 2 days

issue commentdraveness/blog-comments

NVMe 固态硬盘与键值存储 KVell · SOSP 2019 - 面向信仰编程 · /papers-kvell

感觉生产上现在还用不上所谓『现代 SSD』,可能还得等个几年。

大规模落地确实要一段时间

draveness

comment created time in 3 days

issue openeddraveness/blog-comments

NVMe 固态硬盘与键值存储 KVell · SOSP 2019 - 面向信仰编程

https://draveness.me/papers-kvell/

created time in 3 days

issue commentdraveness/blog-comments

Go 语言 Channel 实现原理精要 · /golang-channel

@WangShuaiNWPU 请问一下,channel是引用类型,那它的拷贝是怎么拷贝的?

为什么要拷贝 channel,你说的是赋值么

只是个指针吗?不应该是拷贝hchan结构体吧

跟 *int 和其他的指针类型没有区别

draveness

comment created time in 4 days

issue commentdraveness/blog-comments

为什么 MySQL 使用 B+ 树· Why's THE Design? · /whys-the-design-mysql-b-plus-tree

有个疑问,为什么数据是选择b+树而部署skiplist来存储呢?跳表能做到无锁,查询性能与b+树差不多,岂不是更好?

B+ 树更适合磁盘访问和存储

draveness

comment created time in 4 days

issue commentdraveness/blog-comments

Golang 并发编程与同步原语 · /golang-sync-primitives

@longyue0521 mutexWoken — 表示从正常模式被从唤醒;这里表述不是很清楚,我对mutexWoken的理解是“用于表示当前有被唤醒/新来的goroutine竞争锁“

是认为 Mutex 可以直接从饥饿模式转到 mutexWoken 么,可以找下相关的代码么

draveness

comment created time in 4 days

startedVictoriaMetrics/metrics

started time in 5 days

issue commentdraveness/blog-comments

谈 Kubernetes 的架构设计与实现原理 · /understanding-kubernetes

大佬,给你提个意见,改改 hugo 模板博客加个侧边目录吧,可读性会好很多,一目了然~

不会写 CSS 啊

draveness

comment created time in 6 days

issue commentdraveness/blog-comments

高可用分布式存储 etcd 的实现原理 · /etcd-introduction

@draveness

咨询下大佬这个任期是怎么配置的呢

只有主节点超时之后才会重新选主,相关的配置看看这个 https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md#--election-timeout

多谢,想再咨询个问题,我看到k8s里面取mvcc中keyvalue结构体中的ModRevision字段作为资源的resourceversion,来源于事务的id,同个事务可能操作多个对象,这样最终k8s里面两个对象的resourcevision不就一样了吗,怎么去区分呢,是不是我理解的有问题

Kubernetes 可以同时操作多个 Resource 么?

draveness

comment created time in 7 days

Pull request review commentkubernetes/kubernetes

Use the cmp.Diff function instead of DeepEqual in framework/runtime tests and plugins defaultpreemption tests

 func TestPostFilter(t *testing.T) { 			}  			gotResult, gotStatus := p.PostFilter(context.TODO(), state, tt.pod, tt.filteredNodesStatuses)-			if !reflect.DeepEqual(gotStatus, tt.wantStatus) {-				t.Errorf("Status does not match: %v, want: %v", gotStatus, tt.wantStatus)+			if diff := cmp.Diff(gotStatus, tt.wantStatus,cmp.Comparer(func(x,y framework.Status) bool{

these changes should be formmatted

HaonanFeng

comment created time in 7 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentdraveness/blog-comments

5.4 Goroutine 和调度器 · Go 语言设计与实现 · /golang-goroutine

  1. Goroutine 上下文切换时间待确认 , 楼主这个坑 还没有填完
  2. goroutine是 localqueue 是 256环装数组 还是需要稍微说明下(计算index 用 mod len(localqueue)) 👍🏻

下一轮 Review 会做出修改

draveness

comment created time in 7 days

issue commentdraveness/blog-comments

为什么 Go 语言没有泛型 · Why's THE Design? · /whys-the-design-go-generics

Go 语言设计与实现, 有pdf文档吗? 多谢

没有文档

是否可以对比下swift的泛型

应该不会做,好久不写了

draveness

comment created time in 7 days

issue commentdraveness/blog-comments

微服务架构的分布式容错 · SOSP 2019 - 面向信仰编程 · /papers-aegean

为什么感觉文章里面说到的问题跟平时遇到的微服务问题不太一样呢?

论文其实使用更正式(formal)的方式对问题进行了建模,但是仔细思考会发现没有太多区别

以主从复制模式为例,这里的主从复制应该是数据库的复制吧,运行业务代码的服务怎么设计主从的问题呢?

如下所示,A、B 和 C 三个服务构成的调用链,如果 B 节点收到 C 节点请求后挂了应该怎么处理?

A -> B -> C

将主从复制应用到微服务中,可能就是 B 服务的副本到请求时将该请求发送给其他副本保证请求不会丢失

A -> B -> C
     |
     v
     B

主从复制这些可能都解决不了微服务中容灾问题,论文给出的解决方案可能是 A 节点同时将数据发送给多个 B 节点,然后它们通过服务器垫片(限流和去重等功能)发送给 C 节点,加上论文中其他的方案可以保证请求得到有效地处理

  -> B
A -> B -> C Shim -> C
  -> B
draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Go 语言 Channel 实现原理精要 · /golang-channel

后面的都是false,我不明白的是为什么同样的代码运行多次,有时候会panic有时候不会~

我执行的每一次都会 panic

draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Go 语言 Channel 实现原理精要 · /golang-channel

@draveness

@wangle201210 能理解的确应该在写入的时候close,但是,如果在外面close的话(当size=2时)为什么有时候不会报错出来呢,反复go run后,隔几次会得到一个没有panic的结果

没有 panic 是因为都发完了才 close

缓冲区size=2时,消费了5个后还剩下5个没有消费的 因为5>2所以缓冲区装不下,会有3个挂在sendq里面 当我再去读取ch时(此时已关闭),会读取到缓冲区的数据 读取后缓冲区就会有空间让sendq里面的数据填充进缓冲区(此时这里就会报错说,不能往closed 的chan里面写入内容) 但是我实际运行的情况是有记录不会panic,直接读取到了对应chan 类型的0值,以下是我反复运行多次后的结果(size=2),第二次并没有panic

你把打印的代码换成下面的,看看 ok 的值

x, ok := <-ch
fmt.Println(x, ok)
draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Go 语言 Channel 实现原理精要 · /golang-channel

@wangle201210 能理解的确应该在写入的时候close,但是,如果在外面close的话(当size=2时)为什么有时候不会报错出来呢,反复go run后,隔几次会得到一个没有panic的结果

没有 panic 是因为都发完了才 close

draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Go 语言 Channel 实现原理精要 · /golang-channel

@wangle201210 因为管道都被 close 了还有写入,应该由写入方 close 管道,这样才不会出问题

func main() {
	size := 2
	ch := make(chan int,size)
	go func() {
		for i := 0; i < 10; i++ {
			ch <- i
		}
+		close(ch)
	}()
	first := 4
	go func() {
		for i := 0; i < first; i++ {
			x := <-ch
			fmt.Printf("ch 中输出了%d\n",x)
		}
	}()
	time.Sleep(time.Second)
-	close(ch)
	for i := 0; i < 10 - first; i++ {
		x := <-ch
		fmt.Printf("ch 中输出了%d\n",x)
	}
}
draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Go 语言接口的实现原理 · /golang-interface

CALL runtime.convT2I(SB) ;; runtime.convT2I(SP, SP+8) 请教一下 这个SB 是怎么 翻译成SP, 和 SP+8 两个变量的,有什么规则吗

理解这段代码的时候可以忽略 SB 这个东西,可以认为 runtime.convT2I 函数接受两个参数,这两个参数都在栈上,分别是 SP 和 SP+8

CALL runtime.convT2I => runtime.convT2I(SP, SP+8)
draveness

comment created time in 8 days

issue commentdraveness/blog-comments

为什么 Redis 选择单线程模型 · Why's THE Design? · /whys-the-design-redis-single-thread

@liuyanghui 文章说redis的处理请求能力在一百万每秒应该是笔误吧,官方给的数据是读写分别在十万/八万每秒

这里可能有误解,我这里的意思是使用 Redis 可以抗住百万级别的 QPS 不是说单机的 Redis..

draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Go 语言内存分配器的实现原理 | Go 语言设计与实现 · /golang-memory-allocator

每一级内存结构都分 scannoscan,我知道这个标记位是为了便于GC。

但他们之间有什么关系?是如何做转换的呢?

是为了方便垃圾回收,scan 和 noscan 分别存储了包含指针的对象和不包含的对象

他们和 mcentralemptynoempty又有什么关系呢?

没啥关系

draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Golang 并发编程与 Context · /golang-context

@yanzhongya 我觉得可以加个 Context 的使用场景便于理解,比如:比如有一个网络请求Request,每个Request都需要开启一个goroutine做一些事情,这些goroutine又可能会开启其他的goroutine。这样的话, 我们就可以通过Context,来跟踪这些goroutine,并且通过Context来控制他们的目的,这就是Go语言为我们提供的Context,中文可以称之为“上下文”。

你的提议没什么问题,但是文章侧重的还是实现而不是实践

draveness

comment created time in 8 days

issue commentdraveness/blog-comments

Kubernetes 贡献指南 - 面向信仰编程 · /kubernetes-contributor

向大佬致敬! 请问,像kubernetes这种特别流行特别活跃的社区,你是如何在一年之类取得社区成员的认可,成为这个社区的一员的呢?

多参与,混脸熟

draveness

comment created time in 8 days

issue commentdraveness/blog-comments

基于关系感知路由的全球流量调度 · SOSP 2019 - 面向信仰编程 · /papers-taiji

@gaocegege Facebook 的 paper 感觉有个特点,就是跟业务太相关,跟之前的 TAO 等等一脉相承 (粉丝留名

毕竟是做社交网络的,不过也有很多与具体业务无关的工作,比如 RocksDB 相关的,从这里能找到很多有意思的工作 https://research.fb.com/publications/

draveness

comment created time in 10 days

issue commentdraveness/blog-comments

为什么 CPU 访问硬盘很慢 - 面向信仰编程 · /whys-the-design-cpu-and-disk

磁头从0磁道(磁盘最边缘)移动到最大磁道(磁盘最内侧)的耗时大约在30-40ms,为何寻道时间一般认为是10ms?

30 ~ 40 ms 的数据是从哪里来的呢

可以用程序访问磁盘文件测出来的,具体步骤是:

  1. 准备一块大的HDD(例如2T),远比内存大(例如内存只有16G);
  2. 对HDD做分区,第一、最后一分区尽量小,保证分区远大于内存但远小于整个磁盘大小(例如各128G);
  3. 在第一分区用随机数写满文件A,最后一分区用随机数写满文件B(即A和B各128G),这样A就接近磁盘最边缘,B就接近磁盘最内侧;
  4. 程序交替读取A和B中的随机块(4K、8K、16K均可),使得绝大部分情况下不会读到缓存,而是让磁盘做长距离寻道操作;
  5. 根据循环N次耗时,可以算出磁头移动的平均耗时。

你这里说的是最长时间不是平均耗时

draveness

comment created time in 10 days

issue commentdraveness/blog-comments

为什么 CPU 访问硬盘很慢 - 面向信仰编程 · /whys-the-design-cpu-and-disk

磁头从0磁道(磁盘最边缘)移动到最大磁道(磁盘最内侧)的耗时大约在30-40ms,为何寻道时间一般认为是10ms?

30 ~ 40 ms 的数据是从哪里来的呢

draveness

comment created time in 10 days

issue commentdraveness/blog-comments

Go 语言的栈内存和逃逸分析 | Go 语言设计与实现 · /golang-stack-management

分段栈机制虽然能够按需为当前 Goroutine 分配内存并且及时减少内存的占用,但是它也存在两个比较大的问题:

如果当前 Goroutine 的栈几乎充满,那么任意的函数调用都会触发栈的扩容,当函数返回后又会触发栈的收缩,如果在一个循环中调用函数,栈的分配和释放就会造成巨大的额外开销,这被称为热分裂问题(Hot split); 一旦 Goroutine 使用的内存越过了分段栈的扩缩容阈值,运行时就会触发栈的扩容和缩容,带来额外的工作量;

这里讲的比较模糊,没看懂 1 巨大的额外开销是什么?

栈的分配和释放

2 额外的工作量是什么,这个在连续栈上也要缩扩容,有区别么? 所以提出之前那个疑问

分段栈中包含扩缩容的阈值,所以栈的大小可能一直都在变

可以看下连续栈的设计文档 https://docs.google.com/document/d/1wAaf1rYoM4S4gtnPh0zOlGzWtrZFQ5suE8qr2sD8uWQ/pub

draveness

comment created time in 11 days

issue commentdraveness/blog-comments

Go 语言接口的实现原理 · /golang-interface

请教一下,itab结构的fun属性的数组长度是编译期确定的吗?

是的,可变长度,但是直接访问长度就是 1

如果一个接口有两个函数,那么其itab.fun属性的数组长度会不会是2呢

不会

draveness

comment created time in 11 days

issue commentdraveness/blog-comments

高可用分布式存储 etcd 的实现原理 · /etcd-introduction

咨询下大佬这个任期是怎么配置的呢

只有主节点超时之后才会重新选主,相关的配置看看这个 https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md#--election-timeout

draveness

comment created time in 11 days

issue commentdraveness/blog-comments

Go 语言数组的实现原理 | Go 语言设计与实现 · /golang-array

@hyzgh ./main.go:7:2: moved to heap: a 不就是逃逸的意思吗?

是啊

draveness

comment created time in 12 days

issue openeddraveness/blog-comments

分布式存储 Ceph 的演进经验 · SOSP 2019 - 面向信仰编程

https://draveness.me/papers-ceph/

created time in 12 days

push eventspectra-fund/V3-Open-API-SDK

draveness

commit sha 3ea59b8926056000eed7cdc4ffa01375dc757aef

fix: remove errchannel in okex drvier

view details

push time in 12 days

issue commentdraveness/blog-comments

Go 语言数组的实现原理 | Go 语言设计与实现 · /golang-array

请教一下两个问题哈

  • 数组元素数量大于4,在静态储存区分配内存时,该内存能够被回收吗?(不在堆上的内存如何回收)

静态存储区的内存是不可变的,只有堆上和栈上的内存会回收

  • 数组元素数量小于等于4,在栈上分配内存,那么如果函数返回数组地址,内存不会逃逸吗?

你可以用下面的代码测试一下,相信结果非常清晰

package main

import "fmt"

//go:noinline
func newArray() *[4]int {
	a := [4]int{1, 2, 3, 4}
	return &a
}

func main() {
	a := newArray()
	fmt.Println(a)
}

$ go build -gcflags='-m' main.go
# command-line-arguments
./main.go:13:13: inlining call to fmt.Println
./main.go:7:2: moved to heap: a
./main.go:13:13: []interface {} literal does not escape
<autogenerated>:1: .this does not escape
draveness

comment created time in 12 days

startedxlab/c-for-go

started time in 12 days

startedpubnative/mysqldriver-go

started time in 13 days

push eventspectra-fund/V3-Open-API-SDK

draveness

commit sha 2da6828bd483eb5a4a6366399da230cd0067e880

perf: use reader pool instead of io.ReadCloser

view details

push time in 14 days

push eventspectra-fund/V3-Open-API-SDK

draveness

commit sha b14323fe2b109c2bbbdafc964421b7e348f01b44

perf: use reader pool instead of io.ReadCloser

view details

push time in 14 days

startedgoogle/flatbuffers

started time in 15 days

push eventspectra-fund/V3-Open-API-SDK

draveness

commit sha 108fe12e4ab358ee629cbcd07fdd9f42188a9130

chore: use optimized flate package

view details

push time in 15 days

push eventspectra-fund/go-binance

Alex

commit sha 097cf4adefa9c31be4a0bab2d613fa8f423ba932

add NewOrderResponseType to futures order service (#159) * add NewOrderResponseType to futures order service * fix: used shared variable in order service test * fix: use newOrderRespType query param

view details

draveness

commit sha c9b50c5eec4b69ed6337da6e7fc12e7329e98e94

feat: update go-binance v2

view details

draveness

commit sha 57fcc04be3fb5951883b790a88e31a439bbd693d

fix: remove silent in websocket service

view details

push time in 15 days

issue commentdraveness/blog-comments

圣杯与银弹 · 没用的设计模式 · /holy-grail-design-pattern

@PasserbyX7 设计模式之三重境界 看山是山:手里有锤子看什么都是钉子 看山不是山:厌倦了模式的嵌套,对曾经的设计深恶痛绝 看山还是山:写完代码后恍然发现,哦,我这里用了xx模式啊 我觉得这篇文章洋洋洒洒,不过是一句“会者不难,难者不会”。我倒觉得初学者应该大胆地用模式,踩过坑了跌得疼了才有后期的返璞归真信手拈来。

很多东西都可以归结到『会者不难,难者不会』,你这里的『总结』和文章中提到的抽象和具体差不多,说一句『会者不难,难者不会』对其他人没太多帮助,只有具体化讲清楚才能让读者真正理解为什么

draveness

comment created time in 15 days

issue commentdraveness/blog-comments

Go 语言内存分配器的实现原理 | Go 语言设计与实现 · /golang-memory-allocator

mcentral的empty和nonempty链表 存储空闲和非空闲,没明白这么设计的原因, 以至于 后来需要向这2个链表扫描如果找不到,则申请内存

这一段逻辑,没看懂,能再解释下为什么要设计2个链表么?

empty 和 nonempty 分别存储了满的 mspan 结构和未满的 mspan 结构,这样无论是回收还是在列表中查找可以用于分配内存的结构体都非常方便

draveness

comment created time in 16 days

issue commentdraveness/blog-comments

基于关系感知路由的全球流量调度 · SOSP 2019 - 面向信仰编程 · /papers-taiji

@haosdent 这个很像阿里之前的单元化, 按照买家用户mod到不同idc.我们的搞法则是直接GeoIP

不过阿里的单元化没有考虑不同用户之间的社交关系

draveness

comment created time in 16 days

issue commentdraveness/blog-comments

Go 语言接口的实现原理 · /golang-interface

如果我们将类型转换成了 interface{} 类型,这边变量在运行期间的类型也发生了变化,获取变量类型时就会得到 interface{}。 这句话咋感觉有点别扭,这个变量如果赋值给一个interface类型,然后这个v变量的类型变成了interface类型,但是对于函数传参的时候是 传值类型,main函数中的v和print函数中的v类型都变成了interface类型?

能给一下前后的变化么...我没懂你想表达啥

draveness

comment created time in 16 days

issue commentdraveness/blog-comments

为什么 Redis 选择单线程模型 · Why's THE Design? · /whys-the-design-redis-single-thread

你文章解释性能瓶颈感觉解释的有问题。 开启多线程是为了提高CPU利用率。CPU密集型的操作不需要开启多线程提高CPU利用率,CPU本来就忙啊,线程数与CPU核心数相同就好了。IO密集型才需要开启多线程,A线程IO操作时CPU需要等待时间很长,这时切换到B线程进行计算操作,提高CPU利用率。 我感觉Reids设计应该是认为单线程IO操作时我CPU等会就等会了,比切换其他线程进行计算还要快。

没理解你的疑问

draveness

comment created time in 19 days

startedgopherdata/gophernotes

started time in 19 days

issue openeddraveness/blog-comments

基于关系感知路由的全球流量调度 · SOSP 2019 - 面向信仰编程

https://draveness.me/papers-taiji/

created time in 20 days

issue commentdraveness/blog-comments

如何调试 Go 语言源代码 | Go 语言设计与实现 · /golang-debug

我是直接下载golang/go tag版本压缩文件,用goland直接打开下载的golang/go目录、来运行标准库里自己的test(不是我自己写的,从外部import的test),如果是非internal包,我直接对源码的改动,跑标准库自己的test是可以跑到的,说明test使用了goland打开的我自己下载源码而不是goroot里的sdk,但是遇到有internal的包,编译标准库test就会失败。

我没有用过 Goland,大概看了下你提出的问题,我有两个一文:

  1. 使用命令行直接跑测试可以执行么
  2. 编译错误的提示是什么,这里只看到了运行成功的输出
draveness

comment created time in 20 days

push eventspectra-fund/V3-Open-API-SDK

draveness

commit sha 4b4217ac09c6aa4c94ed9c5924a07a7930aef240

feat: use 14s instead of 29s

view details

push time in 20 days

delete branch draveness/kubernetes

delete branch : patch-5

delete time in 20 days

issue commentdraveness/blog-comments

如何调试 Go 语言源代码 | Go 语言设计与实现 · /golang-debug

请教下大佬,想运行标准库的test,但是有的包遇到了use of internal package net/http/internal not allowed的问题。如果包内没有引用internal的包就可以调试test,比如database,这个有什么好的解决方法吗

你从外部引用 internal 包是不允许的

draveness

comment created time in 20 days

issue commentdraveness/blog-comments

Go 语言反射的实现原理 · /golang-reflect

楼主,请教一个问题,定义了一下的数据类型

type Status int type RealStatus Status

有没有办法通过反射从 RealStatus Type 获取到 Status 的Type

根据这个 Proposal 可能确实不太行 https://github.com/golang/proposal/blob/master/design/18130-type-alias.md#reflect 但是也不排除它新支持了其他方法

draveness

comment created time in 21 days

Pull request review commentkubernetes/kubernetes

fix: use ">" instead of ">=" in resource allocation

 func (r *resourceAllocationScorer) score( 	var score int64  	// Check if the pod has volumes and this could be added to scorer function for balanced resource allocation.-	if len(pod.Spec.Volumes) >= 0 && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && nodeInfo.TransientInfo != nil {

done

draveness

comment created time in 21 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentkubernetes/kubernetes

fix: use ">" instead of ">=" in resource allocation

/retest

draveness

comment created time in 21 days

push eventdraveness/kubernetes

Draven

commit sha 79f05c65a0fcbf2d0aaf65c2e44dca2197e14cdb

fix: use ">" instead of ">=" in resource allocation

view details

push time in 21 days

Pull request review commentkubernetes/kubernetes

fix: remove useless check in node resources plugin

 func (r *resourceAllocationScorer) score( 	var score int64  	// Check if the pod has volumes and this could be added to scorer function for balanced resource allocation.

@damemi I suppose @draveness was trying to say the logic >= 0 makes no sense as it's always true.

yes

As mentioned in #95146 (comment), checking if len(volumes) > 0 might be the original intention.

Thanks, I'll update the commit here.

draveness

comment created time in 21 days

PullRequestReviewEvent

push eventdraveness/kubernetes

Kubernetes Prow Robot

commit sha 5bbc8e10f33d2df068870c649cdcc763381076c5

Merge pull request #93954 from Miciah/fix-validation-of-ingress-rules-with-wildcard-host Fix validation of ingress rules with wildcard host

view details

Kubernetes Prow Robot

commit sha dcdbae7bb58062b1200f33be6743379ef95aa1b3

Merge pull request #93969 from liggitt/go115 [go115] Require go1.15 in build helper scripts

view details

Kubernetes Prow Robot

commit sha e97978f924942e32a8c8681331ca24c0ba2b778c

Merge pull request #93974 from puerco/changelog-fix-118 Add missing changelog entries for v1.18.7

view details

Benjamin Elder

commit sha be6c81597b44724a468b624c5e8b1787645967b1

upgrade rules_docker

view details

Kubernetes Prow Robot

commit sha 55412b6af1764f8bc3d9dfa8f3bd29f1a65f4590

Merge pull request #93981 from BenTheElder/upgrade-rules-docker upgrade rules_docker

view details

M. Habib Rosyad

commit sha 1e780605a9b8efe9e6914b66f06ebe4d07dcfd8e

fix vendor/k8s.io/apimachinery/pkg/util/framer staticcheck

view details

knight42

commit sha 3cb3356645f2ffebb827b49f2a868da789f83613

test(kubectl): deflake run_kubectl_apply_tests Signed-off-by: knight42 <anonymousknight96@gmail.com>

view details

knight42

commit sha de46e81e74b6bb80a92d8f524ba2b0003b7e9196

fix(pluginwatcher): watch socket dir before traversing it Signed-off-by: knight42 <anonymousknight96@gmail.com>

view details

Kubernetes Prow Robot

commit sha 770a59afc4e5f2226db4d131c0ed2ff728ad8fb9

Merge pull request #93821 from dims/sign-up-dims-for-additional-review-roles Sign up dims for additional review roles

view details

Kubernetes Prow Robot

commit sha fa1a3e0f7457efd1b6d23ef8a96291c8a905aaf5

Merge pull request #93665 from dims/emeritus-bgrant0607 Move bgrant0607 to emeritus status.

view details

Kubernetes Prow Robot

commit sha c2bde256aee355c54f8638f95296327228c7603d

Merge pull request #93990 from knight42/fix/run_kubectl_apply_tests test(kubectl): deflake run_kubectl_apply_tests(round 2)

view details

Danil-Grigorev

commit sha f67774bdb0ec3c3152b869385e4048a9e5fd8d44

Refactor locks on registeredNodesLocks Their presence brought no need, as internal calls were already using atomic operatons such as addNode or GetNode. This lock, instead was blocking volume creation, and destroying the ability to provision volume with `thin` SC. Now the node map will be copied, and all group operatons will be executed on a copy, leaving lock for others to use.

view details

Kubernetes Prow Robot

commit sha a42a1c8dea5ba375402706c54784d9690b5a9ff7

Merge pull request #93921 from zhouya0/never_restart_agnhost_pod [Flaky test]kubectl log test never restart pod

view details

Kubernetes Prow Robot

commit sha d822b8b230bce0178400e8949ff3f45423d315d0

Merge pull request #93972 from puerco/changelog-fix-117 Add missing changelog entries for v1.17.10

view details

Stephen Augustus

commit sha 310730e94a6b69222276d77e81baca2e5b9d5d7f

publishing: Use go1.13.15 for 1.18, 1.17, and 1.16 release branches Signed-off-by: Stephen Augustus <saugustus@vmware.com>

view details

Stephen Augustus

commit sha 6ed4f7cacdbb3619e810265992fa68e6d27d265f

publishing: Use go1.15.0 as default version Signed-off-by: Stephen Augustus <saugustus@vmware.com>

view details

Stephen Augustus

commit sha 7681a3a0db3fc0315e3c9adcb72bd66c2cb9df21

publishing: Drop 'go' field from 'controller-manager' 'master' branch This was previous incorrectly set to go1.13. Dropping the field allows us to pick up the 'default-go-version'. Signed-off-by: Stephen Augustus <saugustus@vmware.com>

view details

Kubernetes Prow Robot

commit sha 3b5aedcef43fa01538518ecbc7de369b27ecd191

Merge pull request #93998 from justaugustus/pub-bot-go publishing-bot: Use go1.15.0 as default version and go1.13.15 for previous releases

view details

wojtekt

commit sha a5b60c352d4457d96a90ddf1479f0833ef36f7d4

Fix bug for inconsistent lists served from etcd

view details

Benjamin Elder

commit sha 885b1bc7200e0abc0b4173cfe53a74b0e3353f53

move krzyzacy to emeritus

view details

push time in 22 days

PR opened kubernetes/kubernetes

fix: remove useless check in node resources plugin

/kind cleanup /sig scheduling

NONE
+2 -2

0 comment

1 changed file

pr created time in 22 days

push eventdraveness/kubernetes

Draven

commit sha 46929c426d2fede5bc27d79c9d9f2148a9c33aca

fix: remove useless check in node resources plugin

view details

push time in 22 days

fork draveness/zk

Native ZooKeeper client for Go

fork in 22 days

issue commentkubernetes/kubernetes

Graduate scheduler framework to GA

But we already have an interface for it. Maybe we can provide a testing package with an implementation of the interface, but the cache itself should remain internal.

Yes, provide helper function is also an option.

ahg-g

comment created time in 22 days

issue commentkubernetes/kubernetes

Graduate scheduler framework to GA

I think we should also expose internal/cache package or provider helper to test the customize scheduling framework plugin.

https://github.com/kubernetes/kubernetes/blob/db9f1e91d977c45fe7df8e1e1bd415a3292995e1/pkg/scheduler/framework/plugins/noderesources/least_allocated_test.go#L289

ahg-g

comment created time in 23 days

issue commentdraveness/blog-comments

Go 语言切片的原理 · /golang-array-and-slice

@draveness

这一块我也不太理解,直接append,不带返回值编译会直接报错,这个意义何在?

不带返回值编译是什么意思,可以给出具体例子么

	var b []int64
	append(b, 1)
	fmt.Println(b)

这种是编译不了的,我没太理解不带回返回值的append是什么时候使用的?

昂,@bluemiaomiao 说的不赋值是不是不覆盖原有变量,这种确实没法编译

draveness

comment created time in 24 days

issue commentdraveness/blog-comments

Go 语言切片的原理 · /golang-array-and-slice

这一块我也不太理解,直接append,不带返回值编译会直接报错,这个意义何在?

不带返回值编译是什么意思,可以给出具体例子么

draveness

comment created time in 25 days

issue commentdraveness/blog-comments

浅谈 Go 语言 select 的实现原理 · /golang-select

  1. 从nil channel收发就永久阻塞, 为什么这么设计?

个人认为从 nil channel 收发在设计上应该有有两个相对合理的选择:崩溃和阻塞,但是如果使用 select 监听多个 Channel 其中只有一个是 nil 并不会永久阻塞,所以我觉得这个选择也算得上是合理:

package main

import (
	"fmt"
)

func main() {
	var fooCh chan int
	barCh := make(chan int)
	
	go func() {
		barCh <- 1
	}()
	select {
	case <-fooCh:
	case <-barCh:
		fmt.Println("bar")
	}
}
draveness

comment created time in a month

issue commentdraveness/blog-comments

为什么 TCP/IP 协议会拆分数据 · Why's THE Design? · /whys-the-design-tcp-segment-ip-packet

@draveness

看了几遍,有些地方不能理解: 如果一个MSS 的大小 小于 MTU 大小 会直接发送给对方吗? 比如 MSS = 600,MTU = 800

MSS 和 MTU 是固定值,这两个是不同层协议的设置

也就是说 MSS只要不超过MTU 就没问题,

对,其实超过也没问题,只是 TCP 的数据会被分成多个数据包发送,然后其中任意一个丢了 IP 协议都会重传所有的数据包

那么一个MTU 内部 会包含多个MSS么

一个 IP 数据包可能包含多个 TCP 数据段(Segment)

不考虑 协议头大小, MTU=2*MSS 我发送3个MSS大小的包给对方, 会发送三个MTU 还是 2个MTU

我觉得这个问题意义不大,而且这个问题自己应该可以想明白,再看下 TCP 和 IP 的协议头

draveness

comment created time in a month

issue commentdraveness/blog-comments

为什么 TCP/IP 协议会拆分数据 · Why's THE Design? · /whys-the-design-tcp-segment-ip-packet

看了几遍,有些地方不能理解: 如果一个MSS 的大小 小于 MTU 大小 会直接发送给对方吗? 比如 MSS = 600,MTU = 800

MSS 和 MTU 是固定值

draveness

comment created time in a month

issue commentdraveness/blog-comments

理解 Golang 哈希表 Map 的原理 · /golang-hashmap

@draveness

@draveness

@draveness

@draveness

growWork(t, h, bucket) ,中找到旧桶的位置,为什么不使用hash&oldbucketmask,而是使用 bucket&h.oldbucketmask(),其中bucket := hash & bucketMask(h.B),

你是觉得这样错了么

我不是觉得错,想知道为啥,它这个意思应该是要获取新桶位置对应原来旧桶的位置把

是啊

那为啥不用原本的key的hash对旧桶的长度取余,而是用key的hash对新桶的长度取余再对旧桶的长度取余,这样算出来感觉不是该key对应旧桶的位置哎.所以有点迷糊

这个是位操作,旧桶数量如果是 4,新桶数量是 8,以前落在 1 号桶的会落在 1 和 5 号,旧桶掩码是 0x11

1 & 0x11 == 1
5 & 0x11 == 1

再看看吧,感觉没啥难理解的

请问下,这样的话扩容还有什么意义呢?当容量扩大一倍后,原来的值会放入两个桶中,那么容量变为原来的两倍了,元素总量也变成两倍了呀~萌新求指教

元素总量是不变的,原来的值会被分流到两个桶中,这样描述可能更精确

那么,以前落在 1 号桶的到底是会落在新的 1号还是5号桶呢?

不一定的,要看这些元素的哈希

draveness

comment created time in a month

issue commentdraveness/blog-comments

理解 Golang 哈希表 Map 的原理 · /golang-hashmap

@draveness

@draveness

@draveness

growWork(t, h, bucket) ,中找到旧桶的位置,为什么不使用hash&oldbucketmask,而是使用 bucket&h.oldbucketmask(),其中bucket := hash & bucketMask(h.B),

你是觉得这样错了么

我不是觉得错,想知道为啥,它这个意思应该是要获取新桶位置对应原来旧桶的位置把

是啊

那为啥不用原本的key的hash对旧桶的长度取余,而是用key的hash对新桶的长度取余再对旧桶的长度取余,这样算出来感觉不是该key对应旧桶的位置哎.所以有点迷糊

这个是位操作,旧桶数量如果是 4,新桶数量是 8,以前落在 1 号桶的会落在 1 和 5 号,旧桶掩码是 0x11

1 & 0x11 == 1
5 & 0x11 == 1

再看看吧,感觉没啥难理解的

请问下,这样的话扩容还有什么意义呢?当容量扩大一倍后,原来的值会放入两个桶中,那么容量变为原来的两倍了,元素总量也变成两倍了呀~萌新求指教

元素总量是不变的,原来的值会被分流到两个桶中,这样可能比较精确

draveness

comment created time in a month

issue commentdraveness/blog-comments

微服务架构的分布式容错 · SOSP 2019 - 面向信仰编程 · /papers-aegean

这篇文章的图片用的新的画图工具?

不是的

draveness

comment created time in a month

issue commentgolangci/golangci-lint

Debug why a private linter was not added to the list

@alexisvisco seems like there is nothing we can do here, except update docs :). Please let me know if it's fine.

I encountered the same problem when dealing with golangci-lint custom plugin feature.

so for private linter, we have to build the golangci-lint with CGO_ENABLED=1 flag from source code to leverage this feature. But I think the extra step breaks the feature since the purpose of go plugin is to load packages without rebuilding the main binary. If we have to rebuild it, why not create a intree plugin instead of the custom one. Please correct me if there's something wrong. :)

alexisvisco

comment created time in a month

issue commentxitongsys/parquet-go

Support type alias encode / decode

hi, @draveness It's supported. please check this pull

This is very very cool, thanks!

draveness

comment created time in a month

issue commentdraveness/blog-comments

Go 语言中的 make 和 new · /golang-make-and-new

@draveness

new分配在heap上还是在stack上首要看的应该是他是否超过内存管理中的32KB的限制的吧。然后才是看是否是逃逸。也就是说new不是肯定分配在heap上的

这个结论是从哪里得到的呢,把下面的代码编译成 SSA 中间代码看一下?

package main

import "fmt"

type Test struct {
	i int
}

func main() {
	a := new(Test)
	fmt.Println(a)
}

$ GOSSAFUNC=main go build main.go

image

https://mp.weixin.qq.com/s/Slf7J6ZP4Uz9ukRc-JORyg 这里看的

这里也没讲 new 关键字的原理,逃逸分析和 new 关键字的编译是两个过程,后面讲到了逃逸分析,具体可以看下栈内存管理一节

draveness

comment created time in a month

issue commentdraveness/blog-comments

Go 语言中的 make 和 new · /golang-make-and-new

new分配在heap上还是在stack上首要看的应该是他是否超过内存管理中的32KB的限制的吧。然后才是看是否是逃逸。也就是说new不是肯定分配在heap上的

这个结论是从哪里得到的呢,把下面的代码编译成 SSA 中间代码看一下?

package main

import "fmt"

type Test struct {
	i int
}

func main() {
	a := new(Test)
	fmt.Println(a)
}

$ GOSSAFUNC=main go build main.go

image

draveness

comment created time in a month

issue commentxitongsys/parquet-go

Support type alias encode / decode

hi, @draveness Thanks your advices. I will add it.

Thanks @xitongsys

draveness

comment created time in a month

issue commentdraveness/blog-comments

从 Kubernetes 中的对象谈起 · /kubernetes-object-intro

k8s里强调的是万物皆资源,是不是可以把本文中的所有“对象”都替换成“资源”

『万物皆资源』这句话是从哪里听来的...

draveness

comment created time in a month

issue commentdraveness/blog-comments

Golang 并发编程与 Context · /golang-context

@GongWilliam “在真正使用传值的功能时我们也应该非常谨慎,不能将请求的所有参数都使用 Context 进行传递,这是一种非常差的设计,比较常见的使用场景是传递请求对应用户的认证令牌以及用于进行分布式追踪的请求 ID。” 其实也说不上是非常差的设计,我记得 gin 框架是将参数放进 Context 进行传递的。

gin的context只是叫context而已 跟这个上下文没关系

不过 gin.Context 也实现了 context.Context 接口

draveness

comment created time in a month

issue commentdraveness/blog-comments

Go 语言接口的实现原理 · /golang-interface

type Duck interface {
	Quack()
}

type Cat struct{}

func (c *Cat) Quack() {
	fmt.Println("meow")
}

func main() {
	var c Duck = Cat{}
	c.Quack()
}

$ go build interface.go
./interface.go:20:6: cannot use Cat literal (type Cat) as type Duck in assignment:
	Cat does not implement Duck (Quack method has pointer receiver)

没有搞懂为嘛不是直接获取对象的地址来调用方法呢?

你从 Cat 结构体到 *Cat 会创建一个新的变量,但是你拿到一个指针却可以访问这个指针指向的结构体

draveness

comment created time in a month

issue openeddraveness/blog-comments

通过流量管理缓解数据中心级故障 · OSDI 2018 - 面向信仰编程

https://draveness.me/papers-maelstrom/

created time in a month

fork draveness/parquet-go

pure golang library for reading/writing parquet file

fork in a month

issue openedxitongsys/parquet-go

Custom type support

Support custom type encode and decode like this

type Custom string

created time in a month

PullRequestReviewEvent
PullRequestReviewEvent

push eventspectra-fund/go-binance

draveness

commit sha f96204fde57baf9bdffa55398b122644d045389d

fix: remove silent in websocket service

view details

push time in a month

more