Skip to content

Instantly share code, notes, and snippets.

Kris Mok rednaxelafx

View GitHub Profile
rednaxelafx / Bar$$$Lambda$101.class.javap
Last active Jun 11, 2020
Example comparison of inner-class anonfunc in Scala 2.11 vs indylambda in Scala 2.12, and how that affects Apache Spark's ClosureCleaner
View Bar$$$Lambda$101.class.javap
# LMF class generated at runtime, dumped via
# <Scala 2.12.2>/bin/scala -cp . -Djdk.internal.lambda.dumpProxyClasses=dumpclasses Bar
$ javap -verbose -private -c -s -l 'Bar$$$Lambda$101.class'
Classfile /private/tmp/dumpclasses/Bar$$$Lambda$101.class
Last modified Apr 30, 2020; size 695 bytes
MD5 checksum 419f2634b1acdf7f40ba0bb7c22eabf4
final class Bar$$$Lambda$101 implements scala.runtime.java8.JFunction0$mcV$sp,scala.Serializable
minor version: 0
major version: 52
rednaxelafx / spark-shell-session
Created Jul 30, 2019
Apache Spark master running on OpenJDK11u
View spark-shell-session
$ bin/spark-shell
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/home/krismok/code/work/oss-spark-readonly/assembly/target/scala-2.12/jars/spark-unsafe_2.12-3.0.0-SNAPSHOT.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
19/07/30 06:03:19 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
rednaxelafx /
Last active Jul 31, 2019
HotSpot C2 SIMD vectorization demo
import java.util.Arrays;
public class TestSIMD {
public static void doCompute(int[] a, int[] x, int[] y, int[] z) {
for (int i = 0; i < a.length; i++) {
a[i] = a[i] + x[i] * y[i] * z[i];
rednaxelafx / command_prompt
Last active Apr 10, 2018
demo C# and Scala's lazy val and lambda capturing
View command_prompt
$ csc test.cs
Microsoft (R) Visual C# Compiler version
Copyright (C) Microsoft Corporation. All rights reserved.
$ mono test.exe eager
$ mono test.exe
$ scalac test.scala
$ java -cp $SCALA_HOME/lib/*:. TestLazy eager
rednaxelafx / clhsdb_session
Created Apr 17, 2017
Figuring out what bytecode scala.Predef$.augmentString corresponded to
View clhsdb_session
$ sudo $JAVA_HOME/bin/java -cp $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB
hsdb> attach 15168
Attaching to process 15168, please wait...
hsdb> class scala.Predef$
scala/Predef$ @0x00000007c003eb60
hsdb> print 0x00000007c003eb60
public final class scala.Predef$ @0x00000007c003eb60
rednaxelafx /
Created Mar 7, 2017
Yet another naive Fibonacci example
import java.util.*;
public class Fib {
static int o = 0;
public static void main(String[] args) {
Scanner in = new Scanner(;
int n = in.nextInt();
long start = System.currentTimeMillis();
int answer = fib(n);
rednaxelafx /
Last active Apr 17, 2018
Demo JDK8 HotSpot C2's escape analysis + lock elision
public class SynchSB {
StringBuilder sb = new StringBuilder();
public synchronized int length() {
return sb.length();
public synchronized StringBuilder append(String str) {
return sb.append(str);
rednaxelafx /
Created Jan 10, 2017
A partial patch to make CRuby 2.3.3 compile with OPT_STACK_CACHING on. Note that this doesn't fully work yet.

This patch fixes issues with building CRuby 2.3.3 with OPT_STACK_CACHING turned on.

Note that it doesn't fully work yet. This patch does allow the core VM to build, producing the miniruby binary. But as soon as it runs any substantial Ruby code, e.g. building the cgi library, it ends up crashing. The implementation in compile.c around iseq_set_sequence_stackcaching() / REPLACE_ELEM and friends is probably where the remaining bug is. It'd be nice to know what caused nobu-san to comment out REPLACE_ELEM in the first place.

$ make install
rednaxelafx / .jrubyrc
Last active Apr 10, 2018
JRuby example of massign (paralle assignment) optimized
View .jrubyrc
rednaxelafx /
Last active Apr 10, 2018 — forked from anonymous/
An example of vtable initialization and package access override, run on Oracle JDK8
package pkga;
public class A {
/* packcage access */ void fun() {
You can’t perform that action at this time.