Skip to content

Instantly share code, notes, and snippets.

Kris Mok rednaxelafx

Block or report user

Report or block rednaxelafx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rednaxelafx
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/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
@rednaxelafx
rednaxelafx / TestSIMD.java
Last active Jul 31, 2019
HotSpot C2 SIMD vectorization demo
View TestSIMD.java
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
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 2.0.0.61404
Copyright (C) Microsoft Corporation. All rights reserved.
$ mono test.exe eager
MainThread
$ mono test.exe
NewTestThread
$ scalac test.scala
$ java -cp $SCALA_HOME/lib/*:. TestLazy eager
@rednaxelafx
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
Password:
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
rednaxelafx / Fib.java
Created Mar 7, 2017
Yet another naive Fibonacci example
View Fib.java
import java.util.*;
public class Fib {
static int o = 0;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long start = System.currentTimeMillis();
int answer = fib(n);
@rednaxelafx
rednaxelafx / SynchSB.java
Last active Apr 17, 2018
Demo JDK8 HotSpot C2's escape analysis + lock elision
View SynchSB.java
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
rednaxelafx / notes.md
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.
View notes.md

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
rednaxelafx / .jrubyrc
Last active Apr 10, 2018
JRuby 9.1.6.0 example of massign (paralle assignment) optimized
View .jrubyrc
jit.dumping=true
jit.logging=true
jit.logging.verbose=true
jit.threshold=500
@rednaxelafx
rednaxelafx / A.java
Last active Apr 10, 2018 — forked from anonymous/A.java
An example of vtable initialization and package access override, run on Oracle JDK8
View A.java
package pkga;
public class A {
/* packcage access */ void fun() {
System.out.println("A::fun()");
}
}
@rednaxelafx
rednaxelafx / TrapDemo.java
Created Oct 22, 2016
Java implicit null check example. Run on Oracle JDK8u101
View TrapDemo.java
public class TrapDemo {
public static void demo(IntBox p) {
int dead = p.value;
if (p == null) return;
p.value = 42;
}
public static void main(String[] args) throws Exception {
demo(null);
}
You can’t perform that action at this time.