Skip to content

Instantly share code, notes, and snippets.

  1. Install package libstdc++6 (Ubuntu 16.04)
  2. Add following to ~/.gdbinit
python
import sys 
sys.path.insert(0, '/usr/share/gcc-9/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
#!/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
  • 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]))
@daverigby
daverigby / fix_date.py
Created September 28, 2015 20:27
fix_date.py - corrects the received date in IMAP folders
#!/usr/bin/python
# fix_date.py - corrects the received date in IMAP folders.
# Description:
# When moving mail between IMAP servers, the received date can become
# reset to the date when the message was added to the new server. This
# script attempts to fix this by setting the received date to the date the
# message was sent.
# Usage:
[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

Step 1 - Gather profile

  1. Install debuginfo package (in addition to main RPM/deb)
  2. Install linux perf tools:
    • RHEL / CentOS / Amazon Linux: yum install perf.
    • Note: CentOS7 has a pretty old version of perf; which includes some issues decoding backtraces via DWARF. Prefer a newer version if possible. I have a local build of 5.11 for CentOS7 at ~/Documents/linux-perf-5.11-with-separate_debuginfo_unwind_fix
  3. Start workload to be measured
  4. Record profile
    1. x86-64:
@daverigby
daverigby / socket_buffer_sizes
Created June 3, 2016 16:26
Q: What happens to socket send/recv buffer sizes after an accept()?
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
void die(const char *f)
{
printf("%s: %s\n", f, strerror(errno));
--- /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