Skip to content

Instantly share code, notes, and snippets.

View bboreham's full-sized avatar

Bryan Boreham bboreham

View GitHub Profile
@bboreham
bboreham / tree.go
Created January 4, 2023 11:01
Tournament Tree aka Loser Tree, in Go
// Loser tree, from https://en.wikipedia.org/wiki/K-way_merge_algorithm#Tournament_Tree
package loser
import (
"math"
)
// Ideally Ordered would be any int, float, etc., bit we need to have a maxVal too, so kludge it.
type Ordered interface{ ~uint64 }
pkg:github.com/prometheus/prometheus/promql goos:darwin goarch:arm64
name old time/op new time/op delta
RangeQuery/expr=a_one,steps=1-8 7.03µs ± 0% 7.02µs ± 0% ~ (p=0.690 n=5+5)
RangeQuery/expr=a_one,steps=10-8 7.24µs ± 1% 7.21µs ± 1% ~ (p=0.222 n=5+5)
RangeQuery/expr=a_one,steps=100-8 10.4µs ± 0% 10.4µs ± 0% ~ (p=0.056 n=5+5)
RangeQuery/expr=a_one,steps=1000-8 32.6µs ± 0% 33.8µs ±11% ~ (p=0.063 n=4+5)
RangeQuery/expr=a_ten,steps=1-8 26.8µs ± 0% 26.8µs ± 1% ~ (p=0.556 n=5+4)
RangeQue
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
@bboreham
bboreham / gist:a20451d25fb79b890295ef05bcadd6e6
Created December 19, 2018 07:01
Presenter's history file
1 kubectl get namespaces
2 kubectl -n weave get pods
3 kubectl create namespace dev
5 watch kubectl get all -n dev
8 kubectl -n weave get pods
12 curl podinfo.dev:9898/version
13 cd ../cluster/un-workshop/dev
14 cd cluster/un-workshop/dev
15 git commit -m "my first deploy" .
16 git push
Story so far is described at https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/csi-client-structure-proposal.md
- linked from https://github.com/kubernetes-client/community/blob/master/design-docs/clients-library-structure.md
Would like libs to be more "fluent" - should join up with the native language features e.g. JavaDoc, per-platform
OpenAPI (Swagger) has limitations which force ugly workarounds.
- e.g. doesn't cover returning different types in response to a call e.g. a result or an error.
- OpenAPI 3 fixes a number of these limitations
Key difficulty is which verbs apply to which objects - Go doesn't natively have this concept.