Skip to content

Instantly share code, notes, and snippets.

View bsidhom's full-sized avatar

Ben Sidhom bsidhom

View GitHub Profile
@bsidhom
bsidhom / ShapelessKryo.scala
Last active October 18, 2015 18:32
Example serialization of a Shapeless record type with Chill/Kryo.
import shapeless._
import shapeless.record._
import shapeless.ops.record.{Keys, Values}
import shapeless.syntax.singleton._
import com.esotericsoftware.kryo.io.{Input, Output}
import com.twitter.chill.ScalaKryoInstantiator
import java.io.ByteArrayOutputStream

Keybase proof

I hereby claim:

  • I am bsidhom on github.
  • I am bigben (https://keybase.io/bigben) on keybase.
  • I have a public key whose fingerprint is 61BA 9BB4 4BAC 8388 3040 7E71 6BE1 D494 151F F268

To claim this, I am signing this object:

2014-10-27 15:59:36 -0700
make
-C
contrib
-f
repackage_system_suitesparse4.make
prefix=/usr/local/Cellar/julia/0.3.2
USE_BLAS64=0
FC=/usr/local/bin/gfortran
@bsidhom
bsidhom / yo_coding.py
Created October 30, 2015 21:04
Yo coding. Turn a message into a sequence of 'yo's and 'yoyo's. Messages are encoded with ASCII and concatenated into a bit string. Each '1' is encoded as a 'yo' and each '0' encoded as a 'yoyo'.
from itertools import zip_longest
def encode(message):
codepoints = list(map(ord, message))
binary_strings = list(map(lambda x: '{0:08b}'.format(x), codepoints))
binary_joined = ''.join(binary_strings)
binary_spaced = binary_joined.replace('', ' ').strip()
return binary_spaced.replace('1', 'yo').replace('0', 'yoyo')
def decode(message):
@bsidhom
bsidhom / BUILD.jni
Created January 26, 2017 23:51
Export jni headers from Bazel.
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
cc_library(
name = "jni",
hdrs = [
":jni.h",
":jni_md.h",
],
@bsidhom
bsidhom / 20170213_conscrypt_before.txt
Created February 14, 2017 00:13
Conscrypt benchmark before change
Benchmark (bufferType) (cipher) (messageSize) (sslProvider) Mode Cnt Score Error Units
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 JDK thrpt 10 8370.918 ± 3056.027 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT thrpt 10 6717.291 ± 1910.555 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT_ENGINE thrpt 10 5393.333 ± 334.320 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 128 JDK thrpt 10 7127.577 ± 768.718 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 128 CONSCRYPT thrpt 10 7146.202 ± 1691.395 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_1
@bsidhom
bsidhom / 20170213_conscrypt_after.txt
Last active February 14, 2017 00:15
Conscrypt benchmark with buffer sharing
Benchmark (bufferType) (cipher) (messageSize) (sslProvider) Mode Cnt Score Error Units
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 JDK thrpt 10 6419.566 ± 347.352 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT thrpt 10 9681.253 ± 2791.642 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT_ENGINE thrpt 10 5695.261 ± 706.072 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 128 JDK thrpt 10 6940.003 ± 1445.030 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 128 CONSCRYPT thrpt 10 6970.830 ± 731.533 ops/s
ClientSocketBenchmark.pingPong N/A TLS_ECDHE_RSA_WITH_AES_128_CBC
@bsidhom
bsidhom / 20170216_conscrypt_after.txt
Created February 16, 2017 08:07
Conscrypt benchmark using copy-at-most-once buffers
Benchmark (bufferType) (cipher) (messageSize) (sslProvider) Mode Cnt Score Error Units
ClientSocketThroughputBenchmark.throughput N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 JDK thrpt 10 0.999 ± 0.001 ops/s
ClientSocketThroughputBenchmark.throughput:messagesPerSecond N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 JDK thrpt 10 1901154.071 ± 24923.793 ops/s
ClientSocketThroughputBenchmark.throughput N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT thrpt 10 0.999 ± 0.001 ops/s
ClientSocketThroughputBenchmark.throughput:messagesPerSecond N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT thrpt 10 3069282.330 ± 36947.136 ops/s
ClientSocketThroughputBenchmark.throughput
@bsidhom
bsidhom / 20170216_conscrypt_before.txt
Created February 16, 2017 08:24
Conscrypt benchmark at head
Benchmark (bufferType) (cipher) (messageSize) (sslProvider) Mode Cnt Score Error Units
ClientSocketThroughputBenchmark.throughput N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 JDK thrpt 10 0.999 ± 0.001 ops/s
ClientSocketThroughputBenchmark.throughput:messagesPerSecond N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 JDK thrpt 10 1865775.406 ± 138317.961 ops/s
ClientSocketThroughputBenchmark.throughput N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT thrpt 10 0.999 ± 0.001 ops/s
ClientSocketThroughputBenchmark.throughput:messagesPerSecond N/A TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 64 CONSCRYPT thrpt 10 3007857.931 ± 64693.066 ops/s
ClientSocketThroughputBenchmark.throughput
@bsidhom
bsidhom / conscrypt-crash.log
Created September 14, 2017 17:44
jdb session showing SslWrapper reuse after finalizer has run
Script started on Thu 14 Sep 2017 05:34:19 PM UTC
sidhom@sidhom-gcs-m:~$ time jdb -Diterations=10 -Dhttp.keepAlive=true -Dbuffer.size=$((8*1024*1024)) -Dchunk.size=$((100*1024*1024)) -classpath gcsjava-assembly-0.1.0.jar com.google.gcsjava.Main 1G.random.dat
Initializing jdb ...
> catch java.lang.NullPointerException
Deferring all java.lang.NullPointerException.
It will be set after the class is loaded.
> stop in org.conscrypt.SslWrapper.close
Deferring breakpoint org.conscrypt.SslWrapper.close.
It will be set after the class is loaded.
> run