C++20's 12 C++20’sCalendars and Time Zones in MSVC Miya Natsuhara ("MEE-yuh Not-soo-HAR-uh") Miya.Natsuhara@microsoft.com Software Engineer, Visual C++ LibrariesWelcome to CppCon 2021! Join leap_seconds (https://youtu.be/WX3OmVu4lAs) • time_zone and time_zone_link (https://youtu.be/MODhhr7m-5s) • system_clock::now(), file_clock, leap second awareness (https://youtu.be/c7DT28TV0AY)9 Part II: Safety The “simple” calendrical types (e.g., day, month, year) are very straightforward – what’s the point in creating types for these concepts at all? Couldn’t we just use unsigned int for each 0 码力 | 55 页 | 8.67 MB | 6 月前3
 绕过conntrack,使用eBPF增强 IPVS优化K8s网络性能(kenieevan@github) Zhiguohong (honkiko@github) Bypassing conntrack: Optimizing K8s Service By Enhancing IPVS with eBPF Agenda 目录 01 Problems with K8s Service How to optimize 02 Comparison with industry Performance Performance measurement 03 04 Future work 05 06 Lessons from eBPF What is K8s Service • It exposes a set of pods via VIP using a load balancer • Two types • ClusterIP provides in-cluster access • NodePort conntrack? • Ingress • Move IPVS Netfilter hook from local-in to PREROUTING • The challenges • Skb’s pointer to route is NULL during PREROUTING • No de-fragment is done during PREROUTING IPVS bypass0 码力 | 24 页 | 1.90 MB | 1 年前3
 C++高性能并行编程与优化 -  课件 - 15 C++ 系列课:字符与字符串: • 0 表示空字符(‘ \0’ ) • 9 表示 Tab 制表符(‘ \t’ ) • 10 表示换行(‘ \n’ ) • 13 表示回车(‘ \r’ ) • 27 表示 ESC 键(‘ \x1b’ ) • 127 表示 DEL 键(‘ \x7f’ )等 • 0~31 和 127 这些整数,就构成了 ASCII 码中控制字符的部分。 关于控制字符的一个冷知识 • 在 Linux 命令行中启动 Ctrl+J 的效果和 Enter 键一样,按 Ctrl+H 的效果和退格键 一样。 • 这是因为 ASCII 表中规定 ^I 就是 ‘ \t’ , ^J 就是 ‘ \ n’ , ^H 就是 ‘ \b’ ,所以以前原始的计算机键盘上其 实还没有 Enter 键,大家都是按 Ctrl+J 来换行的… … • 不过,如果直接在控制台输入 ‘ ^’ 和 ‘ C’ 两个字符并 没有 Ctrl+C 的效果哦!因为 个字符。 C 语言字符串 第 2 章 C 语言中的字符类型 char • char c = ‘a’; • assert(c == 97); • c = c + 1; • assert(c == ‘b’); • C 语言中规定字符类型为 char 类型,是个 8 位整数。 • 这是因为 ASCII 码只有 0~127 这些整数,而 8 位整数的表示范围是 2^8 也就是 0~255 ,足以表示所有0 码力 | 162 页 | 40.20 MB | 1 年前3
 C++23: An Overview of Almost All New and Updated Featuresconsteval { /* A */ } else { /* B */ }  No condition  Braces are mandatory  Effect:  If this statement is evaluated during constant evaluation, then A is executed, otherwise B14 if consteval  Why?  We have std::is_constant_evaluated(), so what’s wrong with: if (std::is_constant_evaluated()) { /*A*/ } else { /*B*/ }  It’s equivalent except for:  if consteval is part of core language, so no wrong is_constant_evaluated() can: if constexpr (std::is_constant_evaluated()) { /*A*/ } else { /*B*/ }15 if consteval  Example: consteval int f(int i) { return i; } constexpr int g(int i) { if0 码力 | 105 页 | 759.96 KB | 6 月前3
 C++20: An (Almost) Complete OverviewChanges the Way We Write Code” -- Timur Doumler Friday, September 18 • 12:00Ranges11 Ranges  What’s a range?  An object referring to a sequence/range of elements  Similar to a begin/end iterator pair Ranges in Practice” -- Tristan Brindle Thursday, September 17 • 12:00coroutines15 Coroutines  What’s a coroutine?  A function,  with one of the following:  co_await: suspends coroutine while waiting error messages: e.g.: void Foo(Incrementable auto t) { ... } class Bar {}; int main() { Bar b; Foo(b); } Error: cannot call Foo() with Bar. Note: concept Incrementablewas not satisfied. “Back 0 码力 | 85 页 | 512.18 KB | 6 月前3
 Working with Asynchrony Generically: A Tour of C++ Executorscompute_intensive(1); }), ex::then(ex::schedule(sched), [] { return compute_intensive(2); }) ); auto [a, b, c] = std::this_thread::sync_wait( std::move(work) ).value(); } Launch three tasks to execute concurrently compute_intensive(1); }), ex::then(ex::schedule(sched), [] { return compute_intensive(2); }) ); auto [a, b, c] = std::this_thread::sync_wait( std::move(work) ).value(); } P2300 proposes these concepts and compute_intensive(1); }), ex::schedule(sched) | ex::then([] { return compute_intensive(2); }) ); auto [a, b, c] = std::this_thread::sync_wait( std::move(work) ).value(); }9 EXAMPLE: LAUNCHING CONCURRENT WORK0 码力 | 121 页 | 7.73 MB | 6 月前3
 C++高性能并行编程与优化 -  课件 - 04 从汇编角度看编译器优化spill )的压力。 • 因此 64 位比 32 位机器相比,除了内存突破 4GB 限制外,也有一定性能优势。 8 位, 16 位, 32 位, 64 位版本 al, ax, eax, rax r15b, r15w, r15d, r15 AT&T 汇编语言 GCC 编译器所生成的汇编语言就属于这种 返回值:通过 eax 传出 movl $42, %eax 相当于: eax = 42; 前 6 个 float 。 addss 是什么意思? • 可以拆分成三个部分: add , s , s 1. add 表示执行加法操作。 2. 第一个 s 表示标量 (scalar) ,只对 xmm 的最低位进行运算;也可以是 p 表示矢量 (packed) ,一次对 xmm 中所有位进行运算。 3. 第二个 s 表示单精度浮点数 (single) ,即 float 类型;也可以是 d 表示双精度浮点数 编译器傻了吗? 为什么编译器不优化掉 *c = *a ? 指针别名现象( pointer aliasing ) 考虑这种调用方式: b 和 c 指向同一个变量。 优化前相当于: b = a; b = b; 最后 b 变成了 a 。 如果优化了: b = b; 最后 b 没有改变。 导致优化后结果不一样,这就是 编译器放弃优化的原因。 告诉编译器别怕指针别名: __restrict 关键字 __restrict0 码力 | 108 页 | 9.47 MB | 1 年前3
 Making Libraries Consumable for Non-C++ DevelopersString encoding is not the same as “width”.What isn’t being declared? struct data_t { int a; int b; }; /* Get data from device ‘dev’. */ data_t get_data_from(size_t dev); What defines how dev is Callee cleanup (stdcall) data_t d = get_data_from(dev); return d.a + d.b;What isn’t being declared? struct data_t { int a; int b; }; /* Get data from device ‘dev’. */ data_t get_data_from(size_t return location consistent? data_t d = get_data_from(dev); return d.a + d.b; data_t d = dev- >get_data_from(); return d.a + d.b;What isn’t being declared? push [esp-4] call data_t get_data_from(unsigned0 码力 | 29 页 | 1.21 MB | 6 月前3
 C++高性能并行编程与优化 -  课件 - 07 深入浅出访存优化可以看到小彭老师电脑上插了 2 块内存,频率都是 2667 MHz ,数据的宽度是 64 位( 8 字节)。 • 理论极限带宽 = 频率 * 宽度 * 数量 2667*16*2=42672 MB/s • 那么,频率相同的情况下,可以考虑插两块 8GB 的内存, 比插一块 16GB 的内存更快,不过价格可能还是翻倍的。 • 系统会自动在两者之间均匀分配内存,保证读写均匀分配 到两个内存上,实现内存的并行读写,这和磁盘 0656 秒。 • 因此带宽是 31198 MB/s 。 • 和理论带宽 42672 MB/s 相差不多,符合我的预期 。 第 2 章:缓存与局域性 针对不同数据量大小的带宽测试 • 我们试试看 a 不同的大小,对带宽有什么影响。 针对不同数据量大小的带宽测试(续) • 可见数据量较小时,实际带宽甚至超过了 理论带宽极限 42672 MB/s ! • 而数据量足够大时, 才回落到正常的带宽 一些物理仿真中,常用到这种形式的迭代法: • for (i=0...n) b[i] = a[i + 1] + a[i - 1]; // 假装是 jacobi • swap(a, b); // 交换双缓冲 • for (i=0...n) b[i] = a[i + 1] + a[i - 1]; // 假装是 jacobi • swap(a, b); // 交换双缓冲 • // 不断反复 ... •0 码力 | 147 页 | 18.88 MB | 1 年前3
 hazard pointer synchronous reclamationSynchronous Reclamation Beyond Concurrency TS2 – Maged Michael A B • B is retired only when A is reclaimed. • User removes A (implicitly removing B) • A has no more inbound links. A is automatically retired calls hazard_pointer_clean_up. • A is reclaimed. B is automatically retired (as a result of calling hazard_pointer_clean_up). • Resource X is shutdown. • B is not yet reclaimed. Counted link Solutions for retired objects. • A retired object can belong to at most one cohort. • The completion of a cohort’s destructor guarantees the completion of all deleters of objects that belong/belonged to the cohort0 码力 | 31 页 | 856.38 KB | 6 月前3
共 60 条
- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 













