Skip to content

Instantly share code, notes, and snippets.

View pnkfelix's full-sized avatar
🍩
re-pat; ex-🥐

Felix S Klock II pnkfelix

🍩
re-pat; ex-🥐
View GitHub Profile
@pnkfelix
pnkfelix / gist:4998570
Created February 20, 2013 19:33
an assert I encountered today
FILE: liquid-resize-norrowed.js
// -*- mode: js2; indent-tabs-mode: nil; -*-
var baz = new Array(100);
function F() { }
baz.__proto__ = new F(); // <-- need this to expose issue
for (var i=0; i < 99; i++) {
// ^-- this threshold needs to be high to expose issue
@pnkfelix
pnkfelix / gist:5031812
Created February 25, 2013 17:57
Attempt to narrow down Math.abs type imprecision/oddities from liquid-resize.js parjs-benchmark
18-56-51 src/parjs-benchmarks (git:(no branch)) % git diff
diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp
index b166722..0ad677d 100644
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -96,6 +96,18 @@ js_math_abs(JSContext *cx, unsigned argc, Value *vp)
{
double x, z;
+#ifdef DEBUG
@pnkfelix
pnkfelix / gist:5039801
Created February 26, 2013 16:25
Demo of how to use `mod math { mod mat; }`
% cat math/mat.rs
pub struct Mat4<T> { x:T }
% cat main.rs
// // Don't do this:
// use math::mat::*;
// // Do this:
mod math { mod mat; }
fn main() {
% git diff
diff --git a/js/src/parjs-benchmarks/nbody.js b/js/src/parjs-benchmarks/nbody.js
index 1a0195e..9055381 100644
--- a/js/src/parjs-benchmarks/nbody.js
+++ b/js/src/parjs-benchmarks/nbody.js
@@ -474,6 +474,22 @@ function emulateNBody(mode, numBodies, ticks) {
const NUMBODIES = 4000;
const TICKS = 10;
-benchmark("NBODY", 1, DEFAULT_MEASURE,
(gdb) r -e 'var libdir="../js/src/parjs-benchmarks/"; var MODE="compare";' ../js/src/parjs-benchmarks/nbody.js
Starting program: /Users/fklock/Dev/Mozilla/iontrail/objdir-dbg-js/js -e 'var libdir="../js/src/parjs-benchmarks/"; var MODE="compare";' ../js/src/parjs-benchmarks/nbody.js
BFD: /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork(i386:x86-64): unknown load command 0x20
Warming up sequential runs
.
Measuring sequential runs
Measuring parallel runs
Assertion failure: hasParallelIonScript(), at /Users/fklock/Dev/Mozilla/iontrail/js/src/jsscript.h:621
[New Thread 0x1f03 of process 71782]
[New Thread 0x2003 of process 71782]
@pnkfelix
pnkfelix / gist:5156629
Created March 13, 2013 21:46
ParJS nbody on a variety of input sizes: 1K, 1.5K, 2K, ..., 8K, 8.5K
Driving Code (put at bottom of nbody.js):
-----------------------------------------
for (var k=1; k < 9; k++) {
benchmark("NBODY_"+k+"K", 1, DEFAULT_MEASURE,
function () { emulateNBody("seq", k*1000, TICKS); },
function () { emulateNBody("par", k*1000, TICKS); });
benchmark("NBODY_"+k+".5K", 1, DEFAULT_MEASURE,
function () { emulateNBody("seq", k*1000+500, TICKS); },
function () { emulateNBody("par", k*1000+500, TICKS); });
@pnkfelix
pnkfelix / gist:5156873
Created March 13, 2013 22:12
ParJS nbody with fixed (and reset) seed, on a variety of input sizes: 1K, 1.5K, 2K, ..., 8K, 8.5K
OVERVIEW
--------
I grabbed http://davidbau.com/encode/seedrandom.js and threw it into parjs-benchmarks. (Can we just add it? Its license looks like it is likely to be compatible, but IANAL.) Then I loaded the file, and changed `emulateNBody` to set the seed before each run:
Here's the description of the concrete changes I made to use the seed and iterate on various workloads.
% diff --git a/js/src/parjs-benchmarks/nbody.js b/js/src/parjs-benchmarks/nbody.js
index 1a0195e..aba2cef 100644
--- a/js/src/parjs-benchmarks/nbody.js
@pnkfelix
pnkfelix / gist:5163856
Created March 14, 2013 18:23
Problem with ParallelGetPropertyIC::reset ?
Top-most portion of backtrace:
#0 js::ion::CodeLocationJump::raw (this=0x7fff5fbd0890) at Assembler-shared.h:444
#1 0x00000001009ea082 in js::ion::PatchJump (jump={raw_ = 0xdeadc0de <Address 0xdeadc0de out of bounds>, absolute_ = true, jumpTableEntry_ = 0xdeadab1e <Address 0xdeadab1e out of bounds>}, label={raw_ = 0x106eee0f6 "<felix-deleted-non-utf8-garbage-in-string>", absolute_ = true}) at Assembler-x64.h:600
#2 0x00000001009e8909 in js::ion::IonCache::reset (this=0x104034698) at /Users/fklock/Dev/Mozilla/iontrail/js/src/ion/IonCaches.cpp:1359
#3 0x00000001009e886f in js::ion::ParallelGetPropertyIC::reset (this=0x104034698) at /Users/fklock/Dev/Mozilla/iontrail/js/src/ion/IonCaches.cpp:1145
#4 0x0000000100947f34 in js::ion::IonScript::purgeCaches (this=0x104034600, c=0x10289dc00) at /Users/fklock/Dev/Mozilla/iontrail/js/src/ion/Ion.cpp:801
Scroll down to bottom to see full backtrace. Something is wrong and niko said it is in code that shu recently touched. Unfortunately it takes a long time for t
(gdb) pwd
Working directory /Users/fklock/Dev/Mozilla/iontrail/objdir-dbg-js.
(gdb) cd /Users/fklock/Dev/Mozilla/iontrail/js/src/parjs-benchmarks
Working directory /Users/fklock/Dev/Mozilla/iontrail/js/src/parjs-benchmarks.
(gdb) r -e 'var libdir="./"; var MODE="compare";' nbody-fail.js
Starting program: /Users/fklock/Dev/Mozilla/iontrail/objdir-dbg-js/js -e 'var libdir="./"; var MODE="compare";' nbody-fail.js
Reading symbols for shared libraries ++++++++.............................................................. done
Warming up sequential runs
.
Measuring sequential runs
fn vec_peek<T>(v: &'r [T]) -> Option< (&'r T, &'r [T]) > {
if v.len() == 0 {
None
} else {
let head = &v[0];
let tail = v.view(1, v.len());
Some( (head, tail) )
}
}