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.
// benchmark Java/Scala BigInt/BitSet implementations | |
import scala.util.Random | |
import scala.collection.mutable | |
import scala.collection.immutable | |
import java.util.BitSet | |
import java.math.BigInteger | |
// derived from https://github.com/alexmasselot/benchmark-bitarray/blob/master/src/benchmark/bitarray/TimeIt.scala | |
def timeInMilli(n: Int, f: () => Unit) = { |
# Description: Boxstarter Script | |
# Author: Jess Frazelle <jess@linux.com> | |
# Last Updated: 2017-09-11 | |
# | |
# Install boxstarter: | |
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force | |
# | |
# You might need to set: Set-ExecutionPolicy RemoteSigned | |
# | |
# Run this boxstarter by calling the following from an **elevated** command-prompt: |
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
I bundled these up into groups and wrote some thoughts about why I ask them!
If these helped you, I'd love to hear about it!! I'm on twitter @vcarl_ or send me an email carl.vitullo@gmail.com
https://blog.vcarl.com/interview-questions-onboarding-workplace/
There exist several DI frameworks / libraries
in the Scala
ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.
A few of the most claimed benefits are the following:
Accessing a subnet that is behind a WireGuard client using a site-to-site setup
We want to access a local subnet remotely, but it is behind a NAT firewall and we can't setup port forwarding. Outgoing connections work, but all incoming connections get DROPPED by the ISP's routing policy.
import java.util.concurrent.atomic.*; | |
import java.util.concurrent.*; | |
public class Main { | |
private static ExecutorService executor = Executors.newFixedThreadPool(2); | |
private static int iterations = 10000000; | |
public static class Runner { | |
// writes to canceled happen before a CAS on suspended | |
// reads on canceled happen after a CAS on suspended |