Skip to content

Instantly share code, notes, and snippets.

@jrudolph
jrudolph / ppm.md
Last active October 31, 2023 13:01
Volume Cartographer PPM file format

Volume Cartographer PPM file format

PPM files map U/V coordinates from flattened surfaces back to the original 3D volume coordinates x/y/z and also provide a normal for every point.

The file has a small header and is otherwise a huge array of double values (in the common case, but see header).

Header

@jrudolph
jrudolph / FreiburgImBreisgau.md
Created August 15, 2023 12:55
Freiburg im Breisgau (as imagined by llama-2-7b.ggmlv3.q4_0.bin)

Freiburg im Breisgau

The town of Freiburg is located in south-western Germany, in the state of Baden-Württemberg, 150 km (93 mi) south-west of Karlsruhe, 110 km (68 mi) west of Strasbourg, France, and 130 km (81 mi) east of the Alpine passes of the Alps.

Geography

Freiburg lies in the extreme south of Baden-Württemberg and is bordered on the west by France. It lies 500 m (1,600 ft) above sea level, within the southern part of the northern Black Forest at the foothills of the Alps, near the confluence of the rivers Singold and Dreisam, in the historical region of Sundgau, locally referred to as Breisgau. Freiburg is in the traditional wine-growing region of Germany and hosts one of the country's largest wine festivals, the Freiburger Weihnachtsmarkt, which takes place from the last weekend in November until the first weekend in December.

Subdivisions

@jrudolph
jrudolph / suggestions.txt
Created August 12, 2023 21:27
Evaluate newhope model on llama2.scala to find algorithmic improvements to its nucleus sampling method
Model from https://huggingface.co/TheBloke/NewHope-GGML
llama2JVM ### Instruction:
llama2JVM Generate scala code that find the the top-p (for nucleus sampling) elements, i.e. the smallest set of elements that reaches a given level `p` of cumulative probability, of an unsorted array of probabilities summing to 1. Expect a power-law distribution, i.e. the number of elements found will be low (< 10). Do not use any data structures besides arrays (in particular, expect that inserting into apriority queue will be too slow). Avoid sorting.
llama2JVM
llama2JVM ### Response:
llama2JVM Here's a possible implementation in Scala that uses binary search and a priority queue to solve this problem.
llama2JVM
llama2JVM ```scala
llama2JVM import scala.annotation.tailrec
@jrudolph
jrudolph / FoldAllocationsForFlameGraph.scala
Created May 3, 2022 09:46
Generate allocation flamegraph from JFR
import akka.actor.ActorSystem
import akka.stream.{ Attributes, FlowShape, Inlet, Outlet, OverflowStrategy }
import akka.stream.scaladsl.{ Compression, FileIO, JsonFraming }
import akka.stream.stage.{ GraphStage, GraphStageLogic, InHandler, OutHandler }
import akka.util.ByteString
import java.io.{ File, FileOutputStream }
import spray.json._
import scala.concurrent.Future
@jrudolph
jrudolph / yugabyte-debugging.md
Last active September 12, 2022 09:27
Yugabyte debugging

Yugabyte Debugging Case Study

Problem

Under load, the yugabyte clusters showed a latency spike ~ every 30 seconds. Latencies went up to 4 seconds.

Analysis

Aside from the main problem, we found that one of the servers in the cluster showed CPU saturation during those spikes. Since the spikes were frequent enough, top could be used to identify the yb-master process as the

@jrudolph
jrudolph / yb-architecture.md
Created April 7, 2022 09:32
Yugabyte Architecture / Implementation Details

As of version 2.12.1.0

https://docs.yugabyte.com/preview/architecture/ has some information but too little about the actual implementation details.

The whole project is written in C++.

Components

  • master(s): provide metadata services and are involved in all kinds of metadata changes, manage the set of tservers, disitrbute tablets to tservers. There's a cluster of masters and RAFT is used to determine a leader. It seems that,
@jrudolph
jrudolph / raspberry-pi.md
Last active January 22, 2022 12:24
Scala Native for Raspberry Pi 1

Here's a quick report that I used this branch to compile a binary for Raspberry Pi 1 using https://github.com/scala-native/scala-native/commit/18114562b28e9301c944f7e142ac92d7edd1058c from scala-native/scala-native#1571.

In a quest to update my daughter's music box based on a Raspberry Pi 1, I tried to use scala-native instead of a regular OpenJDK for running the custom software.

Ultimately, I got something working but it was quite a rocky road (and I'm not sure if I would recommend it instead of using Zulu OpenJDK). As mentioned before somewhere in the PR I had to change NativeConfig to default to a 32-bit architecture.

I'm using this config on the project:

nativeCompileOptions ++= Seq("-target", "arm-linux-gnueabihf", "-fno-builtin", "-fno-exceptions", "-march=armv6", "-v")
@jrudolph
jrudolph / build-yugabyte-locally.md
Last active July 1, 2022 08:58
How to build yugabyte locally
{
"nodes": [
{"id": "n1", "group": 1},
{"id": "n2", "group": 1},
{"id": "n3", "group": 1},
{"id": "n4", "group": 1},
{"id": "n5", "group": 1},
{"id": "n6", "group": 1},
{"id": "n7", "group": 1}
],
@jrudolph
jrudolph / BetterTestOnly.scala
Last active October 23, 2019 08:05
sbt camel case and dot expanding testOnly see https://asciinema.org/a/276464?t=20 for a demo
// copy into project
import sbt._
import Keys._
import Def._
import sbt.Def
import sbt.Defaults.allTestGroupsTask
import sbt.Defaults.loadForParser
import sbt.Project.inConfig
import sbt.internal.util.complete.DefaultParsers