Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.
This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea
| # NVM | |
| curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | |
| export NVM_DIR="$HOME/.nvm" | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
| nvm install 10 | |
| # Yarn | |
| curl -o- -L https://yarnpkg.com/install.sh | bash | |
| export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" |
| package fpmax | |
| import scala.util.Try | |
| import scala.io.StdIn.readLine | |
| object App0 { | |
| def main: Unit = { | |
| println("What is your name?") | |
| val name = readLine() |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE UnsaturatedTypeFamilies #-} | |
| import GHC.TypeLits | |
| import Prelude hiding (Functor, Semigroup) | |
| type Main = (Fizz <> Buzz) <$> (0 `To` 100) |
The following are appendices from Optics By Example, a comprehensive guide to optics from beginner to advanced! If you like the content below, there's plenty more where that came from; pick up the book!
| import com.dimafeng.testcontainers.PostgreSQLContainer | |
| import zio.blocking.{effectBlocking, Blocking} | |
| import zio.{Has, ZLayer, ZManaged} | |
| object TestContainer { | |
| type Postgres = Has[PostgreSQLContainer] | |
| def postgres(version: Option[String] = None): ZLayer[Blocking, Throwable, Postgres] = | |
| ZManaged.make { | |
| effectBlocking { |
I run several K8S cluster on EKS and by default do not setup inbound SSH to the nodes. Sometimes I need to get into each node to check things or run a one-off tool.
Rather than update my terraform, rebuild the launch templates and redeploy brand new nodes, I decided to use kubernetes to access each node directly.
| networking.networkmanager.fccUnlockScripts = [ | |
| {id = "8086:7560"; path = "${pkgs.lenovo-wwan-unlock}/bin/fcc_unlock.sh";} | |
| ]; |