Finding Bugs using Path-Sensitive Static AnalysisFinding Bugs using Path-Sensitive Static Analysis Gábor Horváth Gabor.Horvath@microsoft.com @XazaxHunWelcome to CppCon 2021! Join #visual_studio channel on CppCon Discord https://aka.ms/cppcon/discord the latest announcements Take our survey https://aka.ms/cppconAgenda • Intro to path-sensitive static analysis • Path-sensitive checks in MSVC • A look under the hood • Upcoming features • Lessons Documentation in The Era of Concepts and Ranges – Sy Brand & Christopher Di Bella (Google) • Static Analysis and Program Safety in C+ +: Making it Real – Sunny Chatterjee • In-memory and Persistent0 码力 | 35 页 | 14.13 MB | 6 月前3
C++20: An (Almost) Complete Overviewusing T = typename V::value_type; T x { }; T::static_function(); // ... }; With C++20: [](const vector & vec) { T x { }; T::static_function(); // ... };29 Templated Lambda Expressions ❌73 constinit Static initialization order fiasco Variables with static storage and dynamic initializers bugs due to undefined order of dynamic initializations ❌ Static variables with constant Represents information about a specific location in a source code line, column, file_name, function_name Construct one using source_location::current() Example: void LogInfo(string_view 0 码力 | 85 页 | 512.18 KB | 6 月前3
C++高性能并行编程与优化 - 课件 - 07 深入浅出访存优化aligned_alloc 实现 的。 案例:临时创建的数组 • 临时创建的数组,每次调用 func 都会重 复内存分配一次(进入一次内核态),非 常浪费时间。 解决:手动池化 • 声明为 static 变量,这样第二次进入 func 的时候还是 同一个数组,不需要重复分配内存。 thread_local 表示 如有多个线程,每个线程保留一个 tmp 对象的副本, 防止多线程调用 func Intel Xeon CPU was up to 29 X faster. • By using Morton ordering as an alternative to row-major or column-major data storage, significant speedups can be achieved on the Intel Xeon Phi coprocessor or Intel0 码力 | 147 页 | 18.88 MB | 1 年前3
sync clickhouse with mysql mongodbGROUP BY id HAVING sum(sign)>0 ○ Need to use GROUP BY in every query ○ Not suitable for multi-column primary key Our Solution: PTS Key Features ● Only one config file needed for a new Clickhouse Bob1 2 2 Bob2 1 2 Bob2 3 id name flag 2 Bob1 2 2 Bob2 2 2 Bob2 3 PTS Magical Flag Add new column PTS Magical Flag Why fast? Clickhouse Mutation PTS Magical Flag Why fast? Clickhouse Mutation0 码力 | 38 页 | 2.25 MB | 1 年前3
Что нужно знать об архитектуре ClickHouse, чтобы его эффективно использоватьНельзя писать в сервер, отрезанный от кворума ZK Репликация с точки зрения CAP–теоремы Всё вместе › Column–oriented › Сверхбыстрые интерактивные запросы › Диалект SQL + расширения › Плохо подходит для0 码力 | 28 页 | 506.94 KB | 1 年前3
Analyzing MySQL Logs with ClickHouseClickhouse Answers • 10x+ times space reduction compared to Raw Text Log Files High Compression (column store + LZ4) • Typically 100x faster than MySQL on Single Server • Semi-Linear Scalability0 码力 | 43 页 | 2.70 MB | 1 年前3
Working with Asynchrony Generically: A Tour of C++ ExecutorsCONCURRENT WORK namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler auto sched = pool.get_scheduler(); ex::sender auto work = CONCURRENT WORK namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler auto sched = pool.get_scheduler(); ex::sender auto work = you want to. namespace ex = std::execution; int compute_intensive(int); int main() { unifex::static_thread_pool pool{8}; ex::scheduler auto sched = pool.get_scheduler(); ex::sender auto work =0 码力 | 121 页 | 7.73 MB | 6 月前3
C++高性能并行编程与优化 - 课件 - Zeno 中的现代 C++ 最佳实践 printf 而是别的比较复杂的表达式呢? • 可以用逗号表达式的特性,总是会返回后一个 值,例如 (x, y) 始终会返回 y ,哪怕 x 是 void 也没关系。因此只需要这样写就行: • static int helper = ( 任意表达式 , 0); 顺便一提: lambda 的妙用 • 小彭老师小技巧: • []{ xxx; yyy; return zzz; }() • 可以在表达式层面里插入一个语句块,本 • 1. 该类的构造函数一定在 main 之前执行 • 2. 该类的解构函数一定在 main 之后执行 • 该技巧可用于在程序退出时删除某些文件之类 。 • 这就是小彭老师的静态初始化 (static-init) 大法 。 静态初始化用于批量注册函数 • 我们可以定义一个全局的函数表(右图中的 functab ),然后利用小彭老师的静态初始化 大法,把这些函数在 main 之前就插入到全局 为了寻找思路,我们把眼光挪开全局的 static 变量,来看看函数的 static 变量吧 ! • 众所周知,函数体内声明为 static 的变量 即使函数退出后依然存在。 • 实际上函数的 static 变量也可以指定初始 化表达式,这个表达式会在第一次进入函 数时执行。注意:是第一次进入的时候执 行而不是单纯的在 main 函数之前执行哦 ! 如果函数体内的 static 变量是一个类呢?0 码力 | 54 页 | 3.94 MB | 1 年前3
C++20's milliseconds; using time_point = time_point; static constexpr bool is_steady = false; static time_point now() {} }; static_assert(is_clock_v ); For a type T to qualify as a SYSTEM\CurrentControlSet\Control\LeapSecondInformation • For pre-2018 leap seconds, we maintain a static constexpr table to pull data from. • Note that we don’t currently have a way to detect upcoming October update). • However, because leap seconds happen infrequently, we plan to update this static table periodically so older OSes can still detect more recent leap seconds (they will just need 0 码力 | 55 页 | 8.67 MB | 6 月前3
C++高性能并行编程与优化 - 课件 - 04 从汇编角度看编译器优化!否则编译器看不见函数体里的内容怎么 内联呢? 为了效率我们可以尽量把常用函数定义在 头文件里,然后声明为 static 。这样调用 他们的时候编译器看得到他们的函数体, 从而有机会内联。 内联:当编译器看得到被调用函数( other )实现的时候 ,会直接把函数实现贴到调用他的函数( func )里。 局部可见函数: static 因为 static 声明表示不会暴露 other 给其 他文件,而且 func 也已经内联了 的函数体定义,就会自动内联 内联与否和 inline 没关系,内联与否只取决于是否在同文件,且函数体够小 要性能的,定义在头文件声明为 static 即可,没必要加 inline 的 static 纯粹是为了避免多个 .cpp 引用同一个头文件造成冲突,并不是必须 static 才内 联 如果你不确定某修改是否能提升性能,那你最好实际测一下,不要脑内模拟 inline 在现代 C++ 中有其他含义,但和内联没有关系,他是一个迷惑性的名字 函数里是什么,哪怕 other 在定义他的文件里是个空函数,他也不敢优化掉。 解决方案:放在同一个文件里 结论:避免在 for 循环体里调用外部函数,把他们移到 同一个文件里,或者放在头文件声明为 static 函数。 将 other 放到 和 func 同一个 .cpp 文件里,这样编译器看得到 other 的函 数体,就可以内联化该函数 循环中的下标:随机访问 矢量化失败! 循环中的下标:跳跃访问0 码力 | 108 页 | 9.47 MB | 1 年前3
共 22 条
- 1
- 2
- 3













