C++ 中文周刊 第145期

2024-07-30 14:50:58 浏览数 (1)

RSS https://github.com/wanghenshui/cppweeklynews/releases.atom

欢迎投稿,推荐或自荐文章/软件/资源等评论区留言

本期文章由 黄亮Anthony HNY 赞助

资讯

标准委员会动态/ide/编译器信息放在这里

编译器信息最新动态推荐关注hellogcc公众号 本周更新 2024-01-03 第235期

文章

现代分支预测:从学术界到工业界 https://zhuanlan.zhihu.com/p/675456587?utm_psn=1727335890022830082

看个乐呵, 了解概念对于CPU运行还是有点理解的

LLVM中指令选择的流程是啥样的?https://zhuanlan.zhihu.com/p/675543769?utm_psn=1727335764789129217

LLVM知识,学吧,都是知识,早晚碰到

数据结构】Jemalloc中的Radix Tree https://zhuanlan.zhihu.com/p/675177015?utm_psn=1727335511331631104
解析Jemalloc的关键数据结构 https://zhuanlan.zhihu.com/p/671608149?utm_psn=1727335367877697536

jemalloc最新知识,学吧

Optimizing the unoptimizable: a journey to faster C compile times https://vitaut.net/posts/2024/faster-cpp-compile-times/

编译很慢,怎么抓?

ftime-trace的数据可以放到浏览器的tracing里,比如 chrome://tracing/

firefox可以用这个 https://profiler.firefox.com/from-url/https://vitaut.net/files/2024-hello-before.json/marker-chart/?globalTrackOrder=0&hiddenLocalTracksByPid=65312-fwx3&thread=0&timelineType=category&v=10

我没看懂他是怎么分析出头文件的耗时的,总之,把string前向声明一下

但是这种接口编译不过

因为basic_string<char>找不到实现,怎么破?

然后这个操作就省掉了大量编译时间

Why doesn’t my code compile when I change a shared_ptr(p) to an equivalent make_shared(p)? https://devblogs.microsoft.com/oldnewthing/20240103-00/?p=109228

结构是这样的

能不能换成make_shared?不能,因为是private继承

怎么破?

c tip of week 反射一例
Inside STL: The deque, implementation https://devblogs.microsoft.com/oldnewthing/20230810-00/?p=108587

deque msvc实现有坑爹的地方

gcc

clang

msvc

Block size

as many as fit in 512 bytes but at least 1 element

as many as fit in 4096 bytes but at least 16 elements

power of 2 that fits in 16 bytes but at least 1 element

Initial map size

8

2

8

Map growth

Map shrinkage

On request

On request

On request

Initial first/last

Center

Start

Start

Members

block** map; size_t map_size;iterator first;iterator last;

block** map;block** first_block;block** last_block;block** end_block;size_t first;size_t size;

block** map; size_t map_size;size_t first;size_t size;

Map layout

counted array

simple_deque

counted array

Valid range

Pair of iterators

Start and count

Start and count

Iterator

T* current;T* current_block_begin;T* current_block_end;block** current_block;

T* current; block** current_block;

deque* parent;size_t index;

begin()/end()

Copy first and last.

Break first and first size into block index and offset.

Break first and first size into block index and offset.

Spare blocks

Aggressively pruned

Keep one on each end

Keep all

block size太小了

windows相关
  • • How to allocate address space with a custom alignment or in a custom address region https://devblogs.microsoft.com/oldnewthing/20231229-00/?p=109204
  • • How do I prevent my ATL class from participating in COM aggregation? DECLARE_NOT_AGGREGATABLE didn’t work https://devblogs.microsoft.com/oldnewthing/20240101-00/?p=109214
  • • The case of the vector with an impossibly large size https://devblogs.microsoft.com/oldnewthing/20240105-00/?p=109242

视频

What we've been (a)waiting for? - Hana Dusíková - Meeting C 2023 https://www.youtube.com/watch?v=_Q9tiEa-jG4&ab_channel=MeetingCpp

介绍协程并写了个co curl 有点意思,视频我也传B站了

https://www.bilibili.com/video/BV1NG411B7Fy/

代码在这里 https://github.com/hanickadot/co_curl

开源项目更新/新项目介绍

  • • fmt10.2更新,支持duration打印 %j 还支持这么玩
  • • mp-units 2.1.0 released! https://mpusz.github.io/mp-units/2.2/blog/2023/12/09/mp-units-210-released/

编译期物理计算的

  • • nanobind https://nanobind.readthedocs.io/en/latest/benchmark.html 一个python binding,速度性能都不错,群友kenshin推荐
  • • https://github.com/lhmouse/asteria 一个脚本语言,可嵌入,长期找人,希望胖友们帮帮忙,也可以加群753302367和作者对线
  • • Unilang https://github.com/linuxdeepin/unilang deepin的一个通用编程语言,点子有点意思,也缺人,感兴趣的可以github讨论区或者deepin论坛看一看。这里也挂着长期推荐了

0 人点赞