$ uname -r
import Control.Monad.State.Strict | |
import qualified Data.Map.Strict as Map | |
-- This is the standard fibonacci implementation with exponential complexity. | |
naiveFibs :: Int -> Integer | |
naiveFibs 0 = 0 | |
naiveFibs 1 = 1 | |
naiveFibs n = naiveFibs (n-2) + naiveFibs (n-1) | |
-- For reference, calculating the 35th fibonacci takes 9.49 sec. |
package demo; | |
import java.io.Serializable; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.LinkedHashMap; | |
import java.util.List; |
FROM tomcat:7-jre8-alpine | |
# See https://github.com/jvm-profiling-tools/async-profiler/issues/207 | |
RUN apk update && apk add --no-cache libc6-compat perl openjdk8-dbg | |
RUN mkdir /usr/local/async-profiler/ &&\ | |
wget -O /usr/local/async-profiler/async-profiler.tar.gz https://github.com/jvm-profiling-tools/async-profiler/releases/download/v1.5/async-profiler-1.5-linux-x64.tar.gz &&\ | |
cd /usr/local/async-profiler/ &&\ | |
tar -xvzf async-profiler.tar.gz &&\ | |
rm -f /usr/local/async-profiler/async-profiler.tar.gz |
Deadlocks are extremely difficult to reason about sometimes. We are used to thinking about them in terms of contention over shared resources, with the pair of exclusive locks being a good and relatively canonical example of this phenomenon. However, sometimes you can find yourself in deadlock scenarios which are caused not so much by an improper sequencing of exclusivity, but rather by insufficient buffer capacity!
These kinds of scenarios are a lot rarer and much more difficult to diagnose and describe, which is why I found this particular puzzle so incredibly fascinating. The following is a screenshot from Cities Skylines (I added textual markers and arrows to make things easier to follow). All vehicles pictured are stationary and unable to move, indefinitely:
Do you see the deadlock? It took me a bit to understand it, but this situation can and does arise in software resource contention where it is dramatically harder to conc