Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""Reads from stdin / arguments a sequence of lines which contain an
ISO 8601 timestamp, and outputs to stdout each line with the timestamp
with the delta from the previous line.
In other words, converts a file with absolute timstamps into a file
with relative timestamps since the previous line.
The first line cannot have a delta calculated, so it is reported as
[Wed Mar 15 13:43:09 2023] AuxIoPool1: page allocation failure: order:0, mode:0x1000000(GFP_NOWAIT), nodemask=(null)
[Wed Mar 15 13:43:09 2023] AuxIoPool1 cpuset=/ mems_allowed=0
[Wed Mar 15 13:43:09 2023] CPU: 6 PID: 2760 Comm: AuxIoPool1 Not tainted 4.14.305-227.531.amzn2.aarch64 #1
[Wed Mar 15 13:43:09 2023] Hardware name: Amazon EC2 c6gd.2xlarge/, BIOS 1.0 11/1/2018
[Wed Mar 15 13:43:09 2023] Call trace:
[Wed Mar 15 13:43:09 2023]  dump_backtrace+0x0/0x190
[Wed Mar 15 13:43:09 2023]  show_stack+0x24/0x30
[Wed Mar 15 13:43:09 2023]  dump_stack+0x98/0xc8
[Wed Mar 15 13:43:09 2023]  warn_alloc+0x11c/0x1b4
  • Expressions on different stats - doesn't work due to extra name label which we need to discard:
sum without (name) (kv_ep_db_data_size_bytes{bucket="$bucket"}) / sum without (name) (kv_ep_db_file_size_bytes{bucket="$bucket"})

Heatmaps

Note: Set chart type to 'Heatmap' (top right), Series format to 'Heatmap'

  • Heatmap of KV opcode latencies:
sum by(le) (rate(kv_cmd_duration_seconds_bucket{opcode="ADD", bucket="$bucket"}[5m]))
--- /Users/dave/Documents/MBs/MB-53924-v8_dyld/v8-8.3-cb5/libv8.dylib.load-commands	2022-09-30 19:52:49.000000000 +0100
+++ /Users/dave/Documents/MBs/MB-53924-v8_dyld/v8-10.7.21/libv8.dylib.load-commands	2022-09-30 19:53:03.000000000 +0100
@@ -1,23 +1,23 @@
-/Users/dave/Documents/MBs/MB-53924-v8_dyld/v8-8.3-cb5/libv8.dylib:
+/Users/dave/Documents/MBs/MB-53924-v8_dyld/v8-10.7.21/libv8.dylib:
 Load command 0
       cmd LC_SEGMENT_64
-  cmdsize 632
+  cmdsize 712
@daverigby
daverigby / cb_build_times_macos.md
Last active February 11, 2022 13:33
CB build times on macOS

Results

TL;DR: Apple M1 Pro is ~3x faster to build compared to i9-8950HK (Coffee Lake).

MacBook Pro 2018

MacBook Pro (15-inch, 2018)
Processor: 2.9 GHz 6-Core Intel Core i9-8950HK CPU Memory: 16 GB 2400 MHz DDR4

155.7s

@daverigby
daverigby / ns_server REST commands.md
Last active December 9, 2021 16:07
Useful ns_server REST commands
  • Change num_writer_threads from command-line
curl --user Administrator:asdasd -X POST --data "num_writer_threads=disk_io_optimized" http://localhost:9000/pools/default/settings/memcached/global

(Can also use num_reader_threads, and specify an exact number)

  • Change number of shards from command-line:
curl -i -u Administrator:asdasd --data 'ns_bucket:update_bucket_props("default", [{extra_config_string, "max_num_shards=64"}]).' http://localhost:9000/diag/eval
@daverigby
daverigby / local_manifest.xml
Last active June 15, 2021 14:56
Repo manifest: override using local manifest
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="gerrit" fetch="ssh://review.couchbase.org:29418/" />
<remove-project name="build" />
<project path="cbbuild" name="build" remote="gerrit" revision="refs/changes/28/155828/1" groups="notdefault,build" />
</manifest>
@daverigby
daverigby / path_queue_depth.cc
Created April 30, 2021 11:37
Determine the maximum number of requests (OS-level queue depth) for the given file path
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
#include <string>
int main(int argc, char** argv) {
if (argc != 2) {

KV-Engine Bug Triage

Triage, noun: the process of determining the most important people or things from amongst a large number that require attention.

The aim of Bug Triage is to perfom an initial analysis of all new bugs, to determine is (a) they are a valid KV-Engine bug and (b) how important it is to fix.

After Triage a bug should either:

  • Be accepted as a valid KV-Engine bug, and have a suitable Priority and position in the Backlog, or
  • Be rejected as not a valid KV-Engine bug, and:
  • Assigned to the appropriate other team to investigate, or
(gdb) disas
Dump of assembler code for function _ZN8phosphor8TraceLog14getChunkTenantEv:
=> 0x00007ff6391ec420 <+0>: push %r12
0x00007ff6391ec422 <+2>: push %rbp
0x00007ff6391ec423 <+3>: mov %rsi,%r12
0x00007ff6391ec426 <+6>: push %rbx
0x00007ff6391ec427 <+7>: mov %rdi,%rbx
0x00007ff6391ec42a <+10>: sub $0x10,%rsp
0x00007ff6391ec42e <+14>: data16 lea 0x208aca(%rip),%rdi # 0x7ff6393f4f00
0x00007ff6391ec436 <+22>: data16 data16 callq 0x7ff6391de2e0 <__tls_get_addr@plt>