Skip to content

Instantly share code, notes, and snippets.

View mpenick's full-sized avatar
🍵

Michael Penick mpenick

🍵
View GitHub Profile
package main
import (
"fmt"
"net"
)
func main() {
ip := net.ParseIP("1.2.3.4")
mask := net.IPMask(net.ParseIP("255.255.0.0"))
func main() {
defer func() {
if r := recover(); r != nil {
panic("never called")
}
}()
// fatal error: concurrent map writes
m := make(map[int]int)
for i := 0; i < 100; i++ {
@mpenick
mpenick / echo-go-rust-bench.md
Created December 22, 2023 15:42
Buffer size makes a huge difference!

Results

Lang Buffer Size 100c/10s 100c/60s
Go 1kb 475.944 Mbps 437.203 Mbps
Go 8kb 1993.027 Mbps 1976.818 Mbps
Go 16kb 2027.369 Mbps 2048.668 Mbps
Rust 1kb 1672.325 Mbps 1661.514 Mbps
Rust 8kb 2242.304 Mbps 2385.639 Mbps
Rust 16kb 2121.545 Mbps 2197.390 Mbps
@mpenick
mpenick / Cargo.toml
Created August 27, 2023 21:15
A quick port of the Python Drain3 to Rust
[package]
name = "drain"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
lru = "0.11"
@mpenick
mpenick / bootstrap.ldif
Created August 16, 2022 17:04
Using LDAP with Stargate and DSE
# Test file that create a single group "sys_admin" and to users "test" and "test2"
# Passwords are always: test
version: 1
# Entry 1: ou=groups,dc=example,dc=org
dn: ou=groups,dc=example,dc=org
objectclass: organizationalUnit
objectclass: top
ou: groups
# nb -v run driver=http yaml=http-rest-timeseries tags=phase:schema host=my_stargate_host stargate_host=my_stargate_host auth_token=$AUTH_TOKEN
description: |
This workload emulates a time-series data model and access patterns.
This should be identical to the cql variant except for:
- We can't specify the write timestamp to make the write idempotent like we can with cql.
- The `time` binding has to have a StringDateWrapper to get the exact format that the REST API needs; See https://github.com/stargate/stargate/issues/532.
- We need to URLEncode the `data` binding because newlines can't be sent in REST calls.
- Schema creation is cql of the lack of being able to define compaction strategy in the REST API.
- There is no instrumentation with the http driver.
- There is no async mode with the http driver.
package sugar
import (
"errors"
"github.com/stargate/stargate-grpc-go-client/stargate/pkg/client"
pb "github.com/stargate/stargate-grpc-go-client/stargate/pkg/proto"
"google.golang.org/grpc"
)
func NewClusterFromBundle(bundlePath string) (*gocql.ClusterConfig, error) {
reader, err := zip.OpenReader(bundlePath)
if err != nil {
return nil, err
}
defer reader.Close()
contents := make(map[string][]byte)
@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