Company
Date Published
Author
Maksim Kita
Word count
3061
Language
English
Hacker News points
2

Summary

Vectorization is an optimization technique where data is processed using vector operations instead of scalar operations, allowing modern CPUs to take advantage of SIMD instructions. The compiler can automatically vectorize certain loops, but manual vectorization or designing SIMD-oriented algorithms are also possible. However, this can compromise portability if targeting older hardware. Runtime CPU dispatching allows for dynamic selection of the most performant implementation based on the available instruction set, which can improve performance by compiling parts of code multiple times for different architectures. Performance tests and configuring compilers with various options can help identify places to optimize, and applying CPU dispatch manually or using a framework like ClickHouse's can lead to significant improvements in certain cases, such as aggregate functions like sum and avg, and unary functions like roundDuration.