#411 Turning Back Time: Strings, Locks and Garbage Collectors in Java
Java's early API design strengths versus verbose C++/STL manuals, the Java 7 String.substring behavior change from an O(1) view over the character array to an O(n) copy, substring performance regressions at Google, implementing a custom substring as a workaround, designing APIs without knowing future customers, the SPEC JVM98 jack parser generator throwing an exception per matched token, exceptions used for control flow violating the exceptions-are-exceptional principle, JVM benchmarks skewed toward fast exception throwing, ANTLR and JavaCC as later parser tools, class loaders pairing a type with a runtime notion, ClassNotFoundException thrown from nested jar files, the DaCapo benchmark as a test of exception-throwing speed, Effective Java advice to return interfaces such as Map instead of HashMap, why substring should have returned CharSequence, the argument that String should be an interface and CharSequence the concrete type, CharSequence length limited to int and capped at 2GB, Guava Rope as a collection of CharSequences unable to implement CharSequence because of the int length limit, signed versus unsigned sizing of arrays and strings, byte signed and char unsigned inconsistencies, StringBuilder versus StringBuffer, the race condition avoided by StringBuilder cloning its array in toString, StringBuffer passing array ownership under a lock, biased locking making uncontended locks cheap, the Attack of the Clones problem of defensive cloning, optimizing clones away in the JVM, transactional memory as an alternative to locking, copy-on-write and CopyOnWriteArrayList, Swift copy-on-write, Linux kernel read-copy-update and epochs, writing the Azul C4 garbage collector, the C4 read barrier now used in ZGC and Shenandoah, moving Azul from custom hardware read-barrier instructions to x86, the two-space invariant in concurrent copying collectors, IBM Metronome fixups versus two-space invariants, detecting same-page references by XOR of two pointers, trading computation for memory accesses in read barriers, the Transitive Corporation binary translator, Rosetta for Apple and a Sparc-to-Power translator behind IBM's planned Sun acquisition, writing Android Runtime ART, ahead-of-time compilation of Dex replacing Dalvik, disk-size constraints of AOT compilation, Hans Boehm and sticky mark bits for generational marking without moving objects, ART generational concurrent garbage collection in Android KitKat, HashMap interface dispatch replacing LinkedList iteration from JikesRVM, alphabetically sorted interfaces putting AbstractCollection first, Google Maps interface dispatch consuming half the frame time, frame-rate and pause-time gains from ART, WhatsApp broken by an unbalanced-lock bytecode obfuscator, balanced locks required for biased locking, thread safety annotations in Clang/LLVM guarding the Java heap, the mutator lock and stale pointer risks, a reader-writer lock model of the Java heap, managing risk when replacing an operating system runtime, CyanogenMod as a delivery path for ART, Project Valhalla value types, current work on the Linux perf tool and observability, OProfile origins, GPU versus CPU visibility in system tools
Ian Rogers on linkedin: irogers