Skip to content

Instantly share code, notes, and snippets.

View li1's full-sized avatar

Malte Sandstede li1

View GitHub Profile
@li1
li1 / pagingtests.jl
Last active April 22, 2020 14:03
Comparison of hand-written allocation vs. Julia GC for buffer management
module pagingtests
using Blobs
import Blobs
free_mem() = Sys.free_memory() / 2^20
const MB = 2^20
const MEMTARGET = 2048MB
const STATIC_SLOTS = convert(Int, MEMTARGET/MB/8)
@li1
li1 / main.rs
Created August 19, 2019 15:55
ST2 broadcast join
use std::time::Duration;
use std::sync::{Mutex, Arc};
use std::path::PathBuf;
use tdiag_connect::receive as connect;
use tdiag_connect::receive::ReplaySource;
use timely::dataflow::operators::capture::replay::Replay;
use timely::dataflow::operators::inspect::Inspect;
use timely::logging::TimelyEvent;
@li1
li1 / install_mosh_locally.sh
Created July 22, 2019 08:56
install mosh locally (updated june 2017)
#!/bin/bash
# 2017-06 (paulirish): updated for latest sources
# and incorporated fixes from my comments here: https://gist.github.com/xiaom/8264691#gistcomment-1648455
# 2015-ish (zmil): this script does absolutely ZERO error checking. however, it worked
# for me on a RHEL 6.3 machine on 2012-08-08. clearly, the version numbers
# and/or URLs should be made variables. cheers, zmil...@cs.wisc.edu
set -x
@li1
li1 / main.md
Created June 18, 2019 16:04
Minimal example for a profiled SnailTrail computation

Preparing the target computation

Add following dependencies to your Cargo.toml:

[dependencies]
logformat = { git = "..." }
timely_adapter = { git = "..." }
@li1
li1 / reorder.rs
Created March 20, 2019 20:00
reorder operator example
use std::collections::HashMap;
use timely::dataflow::channels::pact::Pipeline;
use timely::dataflow::operators::generic::Operator;
use timely::dataflow::operators::unordered_input::UnorderedInput;
use timely::dataflow::operators::Inspect;
fn main() {
timely::execute_from_args(std::env::args(), |worker| {
let (mut input, cap) = worker.dataflow::<usize, _, _>(|scope| {
let mut queues = HashMap::new();
@li1
li1 / diff_formatter.clj
Last active February 11, 2019 10:07
Formats 3DF diffs as they arrive in the repl into a more concise form
(ns diff-formatter)
(defn- extract-contents [[_ var-map time diff]]
(let [vars (map (comp read-string second) (re-seq #"\{\".*?\":(.*?)\}" var-map))]
[vars (read-string time) (read-string diff)]))
(defn format-diffs [data]
(let [[_ name content] (re-find #"\[\"(.*?)\",(.*)\]" data)
content-details (re-seq #"\[\[(?:(.*?)\],(\d+),(-?\d))*?\]" content)]
[name (map extract-contents content-details)]))
@li1
li1 / main.rs
Last active January 28, 2019 10:45
Transform 3DF pull query to nested graphQL expression
use std::collections::BTreeMap;
use std::hash::Hash;
#[derive(Debug)]
enum NestedVal<T: Eq + Hash> {
Map(BTreeMap<T, NestedVal<T>>),
Arr(Vec<NestedVal<T>>),
Val(T),
}
@li1
li1 / group_experiments.rs
Created January 27, 2019 17:12
Understanding differential's group operator
use differential_dataflow::input::InputSession;
use differential_dataflow::operators::consolidate::Consolidate;
use differential_dataflow::operators::Group;
fn main() {
timely::execute_from_args(std::env::args(), move |worker| {
let mut input = InputSession::new();
worker.dataflow(|scope| {
input
@li1
li1 / core.clj
Last active January 27, 2019 17:02
Transform 3DF pull paths into GraphQL-like nested maps
(ns merge.core)
(def unplanned-data
[[:loans :3 :amount 100]
[:loans :3 :from :1]
[:loans :3 :from :1 :name "a"]
[:loans :3 :observer :1]
[:loans :3 :observer :1 :name "a"]
[:loans :3 :observer :2]
[:loans :3 :observer :2 :name "b"]
@li1
li1 / lib.rs
Created January 19, 2019 19:42
Linked List in Rust
#![deny(missing_docs)]
//! A simple, mutable, single-linked list implementation,
//! following the tutorial [Learning Rust with entirely too many linked lists](http://cglab.ca/~abeinges/blah/too-many-lists/book/README.html),
//! updated for "modern" iterator implementation using traits
/// A mutable, singly linked list
#[derive(Default)]
pub struct List<T> {
head: Link<T>