4 ms·
I'd love to see an evolved C that targets the most performance-obsessed programmers. Features like: * fine-grained control over alignment * automatic generati
by blt 11y ago
I'd love to see an evolved C that targets the most performance-obsessed programmers. Features like:
* fine-grained control over alignment
* automatic generation of SoA code from AoS code
* first-class SIMD types
* pragmas to switch the compiler into branch-avoiding codegen
* cache line size as a built-in constant, with ability to compile a binary that contains several versions of the complete program optimized for different cache line sizes
* user-defined calling conventions
* vectors, matrices, and quaternions (taking care of 90% of the cases where you really want operator overloading in C++)
* ability to treat an integer as an array of bits, bytes, or smaller integers, a la Terry Davis's "Holy C"
And the standard library could contain some nice performance-oriented stuff like:
* portable memory allocator that exposes pages, virtual memory indirection, reserve vs. commit, etc.
* fixed-point math
* approximate transcendental functions
* bitwise stuff a la the "Stanford Bit Twiddling Hacks"
while also adding modules and cleaning up declarations like C2 does.
I think a lot of programmers would like it.
- theseoafs 11y agoThe main issue would be fixing the problem of pointers; high-performance code is hard to write in C because of pointer aliasing. Rust has an interesting approach in its ownership model but I think a performance-oriented C evolution would require another more general solution.
- ori_b 11y agoIn Myrddin[1], the code is amenable to loop versioning -- All references are bounded, one way or the other. Either you have a raw pointer, which is bounded by the size of the type, or you have a slice, which carries with it a length. This allows you (or the compiler) to trivially write an 'aliases(a, b)' predicate, which allows the compiler to write something like: if aliases(a, b) slowpath else fastpath ;; Considering that this language seems to also keep track of bounds on the pointers, you could probably do something similar. [1]http://eigenstate.org/myrddin/ http://eigenstate.org/myrddin/
- aidenn0 11y agoANSI rules for aliasing, plus the restrict keyword go a long way to address this.
- danieltillett 11y agoYes. Pointers are only a problem if you do things with them that confuses the compiler. As someone who writes C code that needs maximum performance (my problem is cpu bound) the two biggest performance gains were moving to icc (Intel’s compiler) and writing my own thread-safe memory pool allocator to avoid malloc.
- arthurcolle 11y agoWhat are your use cases that require this kind of performance? High performance order matching or other trading/financial applications?
- danieltillett 11y agoDNA sequencing data processing [1]. It is a hard problem that needs a lot of processing power thrown at it to solve. 1. https://www.nucleics.com/peaktrace/peaktrace-basecaller-overview.html https://www.nucleics.com/peaktrace/peaktrace-basecaller-over...
- zenogais 11y agoJonathan Blow is working on at least part of this (sorry, the only links I could find were to his videos about it) https://www.youtube.com/watch?v=UTqZNujQOlA https://www.youtube.com/watch?v=UTqZNujQOlA