Skip to content

Instantly share code, notes, and snippets.

View vtjnash's full-sized avatar

Jameson Nash vtjnash

View GitHub Profile
@vtjnash
vtjnash / ccall-of-the-future.md
Created August 13, 2015 19:34
ccall-of-the-future

This was too good to pass up https://youtu.be/xUP3cSKb8sI?t=28m53s (besides, I'd already done this 2.5 years ago, but it wasn't quite complete enough to show anyone).

time = CCall{:time, :libc, Ptr{Void}, Tuple{Ptr{Void},}}()
time(C_NULL)
immutable CCall{Name, Lib, R, A} end
@generated function call{Name,Lib,R,A}(::CFunction{Name,Lib,R,A}, args...)
@vtjnash
vtjnash / vmware-fusion-optimizations.txt
Last active February 23, 2024 05:46
vmware-fusion-optimizations
mainmem.backing = "swap" # disable swapping
MemTrimRate = "0" # disable returning unused memory to the host
sched.mem.pshare.enable = "FALSE" # disable page sharing
prefvmx.useRecommendedLockedMemSize = "TRUE" # force memory to be pre-allocated on host
scsi0.virtualDev = "pvscsi" # fasted disk i/o subsystem (requires driver off pvscsi.flp floppy disk image)
scsi0:0.virtualSSD = 1 # if running off an SSD
## also, preallocate the VMDK disks
#!./julia -f
const n = parse(Int, ARGS[1])
times = Float64[]
for i in 1:n
push!(times, @elapsed begin
f = symbol("f$i")
@eval $f() = $i
@eval $f()
@vtjnash
vtjnash / branch-predict.c
Created June 4, 2016 18:47
branch prediction confusion
#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
__attribute__((noinline)) int footest0();
__attribute__((noinline)) int footest1();
int (*ppfootest[1])() = {&footest0};
int foo;
commit bcfd1decff490724e5c3d6e700c29b7d4b33ebe7
Author: kshyatt <[email protected]>
Date: Thu Jul 7 18:34:16 2016 -0700
Split bitarray up into multiple files to help w/ timeout
~/julia/build-llvm37/test$ JULIA_CPU_CORES=2 make
JULIA build-llvm37/test/all
From worker 3: * strings/util
From worker 2: * strings/search
@vtjnash
vtjnash / mbedtls-debug.diff
Created October 24, 2016 20:10
make mbedtls debug logic usable
Apply the below patch to mbedtls.
Reconfigure with `cmake -D CMAKE_BUILD_TYPE=Debug .` (in the scratch build directory).
Rebuild / reinstall.
Enable debugging with `ccall((:mbedtls_debug_set_threshold, :libmbedtls), Void, (Cint,), 4)`.
diff -rup mbedtls-2.3.0-gpl/library/debug.c mbedtls-2.3.0-gpl-debug/library/debug.c
--- mbedtls-2.3.0-gpl/library/debug.c 2016-06-28 08:42:05.000000000 -0400
+++ mbedtls-2.3.0-gpl-debug/library/debug.c 2016-10-24 15:52:33.152253092 -0400
@@ -59,6 +59,11 @@ void mbedtls_debug_set_threshold( int th
debug_threshold = threshold;
@vtjnash
vtjnash / 00comparison.diff
Last active November 8, 2016 04:31
pkgeval-e597a56ce7
cd scripts && ./runvagrant.sh
./summary.sh 0.*AL/*.json > master.summary
./summary.sh 0.*MZ/*.json > branch.summary
mkdir gist && cd gist
diff -u0 ../master.summary ../branch.summary > 00comparison.diff
cp $(grep tests_fail 00comparison.diff | grep ^+ | cut -c2- | cut -d' ' -f1 | xargs -i find ../0.*MZ -name {}) .
--- ../master.summary 2016-11-07 22:46:37.258892998 -0500
+++ ../branch.summary 2016-11-07 22:47:01.626763797 -0500
@@ -9 +9 @@
@vtjnash
vtjnash / 00comparison.diff
Last active November 21, 2016 17:16
pkgeval-f2de7897a7
cd scripts && ./runvagrant.sh
./summary.sh 0.*AL/*.json > master.summary
./summary.sh 0.*MZ/*.json > branch.summary
mkdir gist && cd gist
diff -u0 ../master.summary ../branch.summary > 00comparison.diff
cp $(grep tests_fail 00comparison.diff | grep ^+ | cut -c2- | cut -d' ' -f1 | xargs -i find ../0.*MZ -name {}) .
ls *.json | xargs -i bash -c 'sed "s/\\\\n/\\n/g" < {} | less'
--- ../master.summary 2016-11-21 11:04:15.840254891 -0500
+++ ../branch.summary 2016-11-21 11:04:28.948186659 -0500
diff --git a/src/interpreter.c b/src/interpreter.c
index 5c89505..d84191d9 100644
--- a/src/interpreter.c
+++ b/src/interpreter.c
@@ -246,6 +246,10 @@ static jl_value_t *eval(jl_value_t *e, interpreter_state *s)
}
else if (ex->head == method_sym) {
jl_sym_t *fname = (jl_sym_t*)args[0];
+ if (jl_is_globalref(fname)) {
+ modu = jl_globalref_mod(fname);
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <sys/time.h>