Beautiful Branchless Binary Search
https://probablydance.com/2023/04/27/beautiful-branchless-binary-search/ [probablydance.com]
2023-04-28 23:45
tags:
compsci
cxx
programming
I read a blog post by Alex Muscar, “Beautiful Binary Search in D“. It describes a binary search called “Shar’s algorithm”. I’d never heard of it and it’s impossible to google, but looking at the algorithm I couldn’t help but think “this is branchless.” And who knew that there could be a branchless binary search? So I did the work to translate it into a algorithm for C++ iterators, no longer requiring one-based indexing or fixed-size arrays.
https://muscar.eu/shar-binary-search-meta.html
source: L
Pointer compression in Oilpan
https://v8.dev/blog/oilpan-pointer-compression [v8.dev]
2022-11-30 03:00
tags:
cxx
malloc
programming
None of this is completely new though, which is why we launched pointer compression for V8 in 2020 and saw great improvements in memory across the web. With the Oilpan library we have another building block of the web under control. Oilpan is a traced-based garbage collector for C++ which is among other things used to host the Document Object Model in Blink and thus an interesting target for optimizing memory.
source: HN
The curious tale of a fake Carrier.app
https://googleprojectzero.blogspot.com/2022/06/curious-case-carrier-app.html [googleprojectzero.blogspot.com]
2022-06-23 22:55
tags:
cxx
exploit
investigation
iphone
security
turtles
Six privilege escalation exploits are bundled with this app. Five are well-known, publicly available N-day exploits for older iOS versions. The sixth is not like those others at all. This blog post is the story of the last exploit and the month-long journey to understand it.
The case of the failed exchange of the vtable slot
https://devblogs.microsoft.com/oldnewthing/20220429-00/?p=106543 [devblogs.microsoft.com]
2022-05-04 20:24
tags:
bugfix
cxx
malloc
programming
windows
This shell extension is trying to detour the operating system, and it failed. (Note that Windows does not support apps detouring the operating system. This shell extension has exited into unsupported territory.)
Changing std::sort at Google’s Scale and Beyond
https://danlark.org/2022/04/20/changing-stdsort-at-googles-scale-and-beyond/ [danlark.org]
2022-04-20 18:32
tags:
bugfix
cxx
library
perf
programming
random
sorting
We are changing std::sort in LLVM’s libcxx. That’s a long story of what it took us to get there and all possible consequences, bugs you might encounter with examples from open source. We provide some benchmarks, perspective, why we did this in the first place and what it cost us with exciting ideas from Hyrum’s Law to reinforcement learning. All changes went into open source and thus I can freely talk about all of them.
This article is split into 3 parts, the first is history with all details of recent (and not so) past of sorting in C++ standard libraries. Second part is about what it takes to switch from one sorting algorithm to another with various bugs. The final one is about the implementation we have chosen with all optimizations we have done.
source: HN
Eliminating Data Races in Firefox – A Technical Report
https://hacks.mozilla.org/2021/04/eliminating-data-races-in-firefox-a-technical-report/ [hacks.mozilla.org]
2021-04-07 00:02
tags:
compiler
concurrency
cxx
development
programming
update
We successfully deployed ThreadSanitizer in the Firefox project to eliminate data races in our remaining C/C++ components. In the process, we found several impactful bugs and can safely say that data races are often underestimated in terms of their impact on program correctness. We recommend that all multithreaded C/C++ projects adopt the ThreadSanitizer tool to enhance code quality.
source: HN
ARM and Lock-Free Programming
https://randomascii.wordpress.com/2020/11/29/arm-and-lock-free-programming/ [randomascii.wordpress.com]
2020-12-11 04:33
tags:
concurrency
cxx
programming
systems
This is intended to be a casual introduction to the perils of lock-free programming (which I last wrote about some fifteen years ago), but also some explanation of why ARM’s weak memory model breaks some code, and why that code was probably broken already. I also want to explain why C++11 made the lock-free situation strictly better (objections to the contrary notwithstanding).
Stupid std::tuple tricks: Getting started
https://devblogs.microsoft.com/oldnewthing/20200622-00/?p=103880 [devblogs.microsoft.com]
2020-07-01 01:57
tags:
cxx
programming
series
Inside std::function
https://devblogs.microsoft.com/oldnewthing/20200513-00/?p=103745 [devblogs.microsoft.com]
2020-05-17 03:25
tags:
cxx
programming
Move, simply
https://herbsutter.com/2020/02/17/move-simply/ [herbsutter.com]
2020-02-18 05:32
tags:
cxx
programming
standard
C++ “move” semantics are simple, but they are still widely misunderstood. This post is an attempt to shed light on that situation.
I like that the appendix is 3 times the article’s length.
source: HN
Speculative Load Hardening
https://llvm.org/docs/SpeculativeLoadHardening.html [llvm.org]
2020-01-09 20:40
tags:
c
compiler
cxx
defense
development
security
sidechannel
While several approaches are being actively pursued to mitigate specific branches and/or loads inside especially risky software (most notably various OS kernels), these approaches require manual and/or static analysis aided auditing of code and explicit source changes to apply the mitigation. They are unlikely to scale well to large applications. We are proposing a comprehensive mitigation approach that would apply automatically across an entire program rather than through manual changes to the code. While this is likely to have a high performance cost, some applications may be in a good position to take this performance / security tradeoff.
Clang format tanks performance
https://travisdowns.github.io/blog/2019/11/19/toupper.html [travisdowns.github.io]
2019-11-19 22:54
tags:
benchmark
c
cxx
perf
programming
turtles
Let’s benchmark toupper implementations.
Actually, I don’t really care about toupper much at all, but I was writing a different post and needed a peg to hang my narrative hat on, and hey toupper seems like a nice harmless benchmark. Despite my effort to choose something which should be totally straightforward and not sidetrack me, this weird thing popped out.
source: L
How can I have a C++ function that returns different types depending on what the caller wants?
https://devblogs.microsoft.com/oldnewthing/20191106-00/?p=103066 [devblogs.microsoft.com]
2019-11-07 03:12
tags:
cxx
programming
type-system
AddressSanitizer (ASan) for Windows with MSVC
https://devblogs.microsoft.com/cppblog/addresssanitizer-asan-for-windows-with-msvc/ [devblogs.microsoft.com]
2019-10-25 04:57
tags:
beta
c
compiler
cxx
development
update
windows
We are pleased to announce AddressSanitizer (ASan) support for the MSVC toolset. ASan is a fast memory error detector that can find runtime memory issues such as use-after-free and perform out of bounds checks. Support for sanitizers has been one of our more popular suggestions on Developer Community, and we can now say that we have an experience for ASan on Windows, in addition to our existing support for Linux projects.
MSVC support for ASan is available in our second Preview release of Visual Studio 2019 version 16.4.
source: white
Common Systems Programming Optimizations & Tricks
https://paulcavallaro.com/blog/common-systems-programming-optimizations-tricks/ [paulcavallaro.com]
2019-09-20 17:09
tags:
concurrency
cxx
perf
programming
Today’s blog post is an overview of some common optimization techniques and neat tricks for doing “systems programming” – whatever that means today. We’ll walk through some methods to make your code run faster, be more efficient, and to squeeze just a little more juice from whatever you got.
source: HN
No-one knows the type of char + char
https://blog.knatten.org/2019/05/24/no-one-knows-the-type-of-char-char/ [blog.knatten.org]
2019-07-13 17:52
tags:
c
cxx
programming
standard
What are “the usual arithmetic conversions”?
source: L
Detecting in C++ whether a type is defined
https://devblogs.microsoft.com/oldnewthing/20190708-00/?p=102664 [devblogs.microsoft.com]
2019-07-11 18:37
tags:
cxx
programming
series
type-system
quinesnake
https://github.com/taylorconor/quinesnake [github.com]
2019-04-30 02:33
tags:
cxx
gaming
programming
tty
A quine that plays snake over its own source!
source: grugq
Modern C++ Won't Save Us
https://alexgaynor.net/2019/apr/21/modern-c++-wont-save-us/ [alexgaynor.net]
2019-04-22 15:44
tags:
cxx
development
programming
security
I would like to credit C++‘s smart pointer types, because they do significantly help. Unfortunately, my experience working on large C++ projects which use modern idioms is that these are not nearly sufficient to stop the flood of vulnerabilities. My goal for the remainder of this post is to highlight a number of completely modern C++ idioms which produce vulnerabilities.
source: L
Usability improvements in GCC 9
https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9/ [developers.redhat.com]
2019-03-08 20:11
tags:
compiler
cxx
development
update
ux
I work at Red Hat on GCC, the GNU Compiler Collection, and I spent most of the past year making GCC easier to use. Let’s look at C and C++ improvements that will be in the next major release of GCC, GCC 9.
C++ error messages that are slowly approaching useful...
source: L