Skip to content

Instantly share code, notes, and snippets.

View m0wfo's full-sized avatar

Chris Mowforth m0wfo

  • Planet Earth
View GitHub Profile
@m0wfo
m0wfo / volatile_write_gen.asm
Created March 23, 2016 22:06
HotSpot-generated assembly for a volatile read + write
0x000000010be89ca3: jmpq 0x000000010be89d1e ;*iload_1
; - com.logentries.blog.VolatileClass::run@2 (line 12)
0x000000010be89ca8: vmovsd 0x10(%rsi),%xmm0 ; implicit exception: dispatches to 0x000000010be89eae
0x000000010be89cad: vmovq %xmm0,%rdx ;*getfield a
; - com.logentries.blog.VolatileClass::run@13 (line 13)
0x000000010be89cb2: movabs $0x1,%r10
0x000000010be89cbc: add %r10,%rdx
0x000000010be89cbf: mov %rdx,0x40(%rsp)
@m0wfo
m0wfo / volatile_gen.asm
Last active March 23, 2016 21:56
HotSpot-generated assembly for a volatile read
0x000000010d6895e3: jmpq 0x000000010d68963c ;*iload_3
; - com.logentries.blog.VolatileClass::run@2 (line 13)
0x000000010d6895e8: vmovsd 0x10(%rsi),%xmm0 ; implicit exception: dispatches to 0x000000010d6897ce
0x000000010d6895ed: vmovq %xmm0,%rdx ;*getfield a
; - com.logentries.blog.VolatileClass::run@12 (line 14)
0x000000010d6895f2: inc %edi
@m0wfo
m0wfo / nonvolatile_gen.asm
Last active March 23, 2016 21:17
HotSpot-generated assembly for a nonvolatile read
0x0000000104287223: jmpq 0x0000000104287276 ;*iload_3
; - com.logentries.blog.NonVolatileClass::run@2 (line 13)
0x0000000104287228: mov 0x10(%rsi),%rdx ;*getfield a
; - com.logentries.blog.NonVolatileClass::run@12 (line 14)
; implicit exception: dispatches to 0x00000001042873fe
0x000000010428722c: inc %edi
@m0wfo
m0wfo / nonvolatile.java
Last active March 23, 2016 21:17
Nonvolatile example
public class NonVolatileClass implements Runnable {
public long a;
@Override
public void run() {
long b;
for (int i = 0; i < 1E9; i++) {
b = a;
}
@m0wfo
m0wfo / volatile.java
Created March 23, 2016 21:16
VolatileExample
public class VolatileClass implements Runnable {
public volatile long a;
@Override
public void run() {
long b;
for (int i = 0; i < 1E9; i++) {
b = a;
}
# Run complete. Total time: 00:01:11
Benchmark Mode Cnt Score Error Units
JMHBenchmark.padded thrpt 25 728583552.130 ± 4268366.821 ops/s
JMHBenchmark.padded:updatePaddedA thrpt 25 363537357.980 ± 2313491.132 ops/s
JMHBenchmark.padded:updatePaddedB thrpt 25 365046194.150 ± 2045685.311 ops/s
JMHBenchmark.unpadded thrpt 25 148478851.964 ± 2746611.843 ops/s
JMHBenchmark.unpadded:updateUnpaddedA thrpt 25 74249061.512 ± 1926331.358 ops/s
JMHBenchmark.unpadded:updateUnpaddedB thrpt 25 74229790.452 ± 1126025.534 ops/s
@JsonIgnoreProperties(ignoreUnknown = true)
public class {
public Integer getValue();
public UUID getTransactionId();
}
package com.logentries.scala
import org.apache.log4j.LogManager
object Main {
def main(args: Array[String]) {
val log = LogManager.getRootLogger()
log.debug("Hello, Scala world!")
Thread.sleep(1000)
1 ; SLIME 20100404
2 user> (ns le-example.core)
3 nil
4 le-example.core> (print-some-logs)
5 nil
6 le-example.core>
@m0wfo
m0wfo / gist:7059473
Last active December 25, 2015 23:49
(ns le-example.core
(:use [clojure.tools.logging :only (info)])
(:gen-class))
(defn print-some-logs []
(dotimes [n 10]
(info "Hello, logger!")))