Skip to content

Instantly share code, notes, and snippets.

View mpenick's full-sized avatar
🍵

Michael Penick mpenick

🍵
View GitHub Profile
@mpenick
mpenick / 70rps-cql-proxy-num-conns-1.csv
Last active February 14, 2022 22:23
cql-proxy 1MB objects
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 4.
cli-arguments
--type selectrate --num-io-threads 1 --hosts 127.0.0.1 --num-core-connections 1 --data-size 1048576 --num-partition-keys 99 --request-rate 70 --num-requests 10000
cli-full-arguments
--hosts "127.0.0.1" --type selectrate --label "" --protocol-version 0 --num-threads 1 --num-io-threads 1 --num-core-connections 1 --coalesce-delay -1 --num-requests 10000 --num-concurrent-requests 5000 --num-partition-keys 99 --data-size 1048576 --request-rate 70 --batch-size 1000 --log-level 2 --sampling-rate 2000 --use-token-aware 1 --use-prepared 1 --use-ssl 0 --use-stdout 0
driver version, server version, num nodes
2.16.2, cassandra-4.0.2, 1
import io.reactivex.Flowable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.immutables.value.Value;
public class Main {
@Value.Immutable
"log"
"net"
"time"
)
func loadBytes(file *zip.File) ([]byte, error) {
r, err := file.Open()
if err != nil {
return nil, err
}
@mpenick
mpenick / main.go
Created March 1, 2021 17:44
Minimal gocql tracing example
package main
import (
"github.com/gocql/gocql"
"log"
)
type MyTracer struct { }
func (t *MyTracer) Trace(traceId []byte) {
@mpenick
mpenick / dial.go
Last active December 4, 2020 18:13
package main
import (
"log"
"net"
"os"
"strconv"
"sync"
"sync/atomic"
"time"
@mpenick
mpenick / some.md
Last active December 3, 2020 15:24

CQL tag:

CREATE ROLE IF NOT EXISTS 'web_user' WITH PASSWORD = 'web_user' AND LOGIN = TRUE;
CREATE KEYSPACE IF NOT EXISTS store WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':'1'};
CREATE TABLE IF NOT EXISTS store.shopping_cart (userid text PRIMARY KEY, item_count int, last_update_timestamp timestamp);
INSERT INTO store.shopping_cart (userid, item_count, last_update_timestamp) VALUES ('9876', 2, toTimeStamp(toDate(now())));
INSERT INTO store.shopping_cart (userid, item_count, last_update_timestamp) VALUES ('1234', 5, toTimeStamp(toDate(now())));
GRANT MODIFY ON TABLE store.shopping_cart TO web_user ;
GRANT SELECT ON TABLE store.shopping_cart TO web_user;
// Done in setup
let xrViewerSpace = await xrSession.requestReferenceSpace("viewer");
let xrReferenceSpace = await xrSession.requestReferenceSpace("some-space-here-like-local-bounded-etc");
// Done per frame
let xrViewerPose1 = xrFrame.getPose(xrViewerSpace, xrReferenceSpace);
#include <cassandra.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <memory>
#include <sstream>
// Requires this PR to reliably query the same coordinator: https://github.com/datastax/cpp-driver/pull/489
package com.datastax;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
import com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder;
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.api.core.metadata.NodeStateListener;
import com.datastax.oss.driver.internal.core.loadbalancing.DcInferringLoadBalancingPolicy;
import java.net.InetSocketAddress;
@mpenick
mpenick / radix_tree_gc.c
Last active May 11, 2020 14:32
A tiny, malloc-based GC that uses a radix tree to store GC metadata (1.5% - 3% overhead)
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define BITMAP_NUM_BITS 64
#define LG_BITMAP_NUM_BITS 6