What branch misprediction does the Branch Target Buffer detect?

This is a good question! I think the confusion that it’s causing is due to Intel’s strange naming schemes which often overload terms standard in academia. I will try to both answer your question and also clear up the confusion I see in the comments. First of all. I agree that in standard computer science … Read more

Logger slf4j advantages of formatting with {} instead of string concatenation

It is about string concatenation performance. It’s potentially significant if your have dense logging statements. (Prior to SLF4J 1.7) But only two parameters are possible Because the vast majority of logging statements have 2 or fewer parameters, so SLF4J API up to version 1.6 covers (only) the majority of use cases. The API designers have … Read more

Can I use the “null pointer optimization” for my own non-pointer types?

As of Rust 1.28, you can use std::num::NonZeroU8 (and friends). This acts as a wrapper that tells the compiler the contents of a number will never contain a literal zero. It’s also why Option<Box<T>> is pointer-sized. Here’s an example showing how to create an Age and read its payload. use std::num::NonZeroU8; struct Age(NonZeroU8); impl Age … Read more

Hyperparameter optimization for Deep Learning Structures using Bayesian Optimization

Although I am still not fully understanding the optimization algorithm, I feed like it will help me greatly. First up, let me briefly explain this part. Bayesian Optimization methods aim to deal with exploration-exploitation trade off in the multi-armed bandit problem. In this problem, there is an unknown function, which we can evaluate in any … Read more

foldl is tail recursive, so how come foldr runs faster than foldl?

Welcome to the world of lazy evaluation. When you think about it in terms of strict evaluation, foldl looks “good” and foldr looks “bad” because foldl is tail recursive, but foldr would have to build a tower in the stack so it can process the last item first. However, lazy evaluation turns the tables. Take, … Read more