活跃农民
- 积分
- 489
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2015-7-13
- 最后登录
- 1970-1-1
|
本帖最后由 iunknown 于 2023-1-24 10:57 编辑
我工作用C++7,8年了,当然也大量用Java。我感觉是这样。如果我面试一个primary language是C++的senior+ candidate,我期待这个candidate有以下技能(时间有限,只是写几个例子):
1. concurrency/async/co-routine/fiber
2. knowledge in perf/latency: numa affinitization, how to saturate cpu, perf/latency profiling etc
3. deep knowledge about memory management: how to avoid unnecessary memcpy, raii pattern etc
4. knowledge about OS kernel
5. Knowledge about network stack: analyze tcpdump etc. ----
以上这些都是单机上的skill,分布式的skill基本和语言无关。
说上面这些的意思是如果你的日常工作语言是C++,但却不能获得以上技能,其实用C++的意义不大。简单来说,用C++的目的是为了take most out of a single machine's resource/maximize per servcie throughput/rps/minimize latency,或者说build high performance *data path* application
补充内容 (2023-01-28 09:12 +8:00):
很惊讶收到这么多赞,我以为这是个小众的话题,当时也没有太认真回复。看到有朋友问哪里去学这类东西。我补充几句,防止误导大家,尤其工作不久的朋友。disclaimer: 我是做分布式系统的,完全不了解C++的其他应用场景。
首先,我之前说的那些知识未必是值得学习的,并没有太多公司/产品需要high performance data path service。如果想一直做distributed system infra的朋友,可以投入精力。即使做infra,对于工作年数不多的朋友,在花费大量时间研究这些topic之前,一定要保证自己先成为distributed system generalist,再去become high performance data path service specialist。
. .и
如果要学习这些我之前提到的topic,最好的方法是你所在公司有已知的这种application。尤其是那种P99 latency在sub millisecond,单机RPS过500k的。这种service大概率都会优化我之前说到的那几个方面。你去看它的code就可以。top performance killer一般就这么几个:
1. memory copy: e.g. if you are doing AES-XTS, are you doing that in-place?
2. system call: minimize the number of syscalls. 例如如果一个service有大量文件/磁盘操作,大概率会使用AIO/io_uring来减少syscall的数量。这也是为什么很多service用user space network/storage stack的原因e.g. DPDK, SPDK.
3. context switch: 之前concurrency/async我已经说过了
4. numa issue: 例如通常要reserve cpu来handle NIC interrupt (尤其NIC没有TCP offloading),而且这个cpu要和process network requests的thread在同一个numa。
5. cache: cache miss, cache false sharing etc.. check 1point3acres for more.
如果自己公司没有这种service,可以看开源的这类产品,但一定要是prod ready的开源产品。 |
|