Skip to content

Instantly share code, notes, and snippets.

@daverigby
daverigby / local_manifest.xml
Last active Jun 15, 2021
Repo manifest: override using local manifest
View local_manifest.xml
<?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 Apr 30, 2021
Determine the maximum number of requests (OS-level queue depth) for the given file path
View path_queue_depth.cc
#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) {
View KV-Engine Bug Triage.md

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
View getChunkTenant (CentOS 8)
(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>
View google_sanitizers_issue_1314 disas.md
  • Lambda t1 (lines 97-101):
(gdb) disas /s 0x00000000004cd7ce
Dump of assembler code for function ScopedEventBaseThreadTest_keepalive_Test::<lambda()>::operator()(void) const:
/home/couchbase/couchbase/tlm/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/io/async/test/ScopedEventBaseThreadTest.cpp:
97	  std::thread t1([&] {
   0x00000000004cd74c <+0>:	push   %rbp
   0x00000000004cd74d <+1>:	mov    %rsp,%rbp
   0x00000000004cd750 <+4>:	push   %rbx
   0x00000000004cd751 <+5>:	sub    $0x2b8,%rsp
View Tsan race - folly v2020.08.24.00
[ RUN ] ExecutorPoolEpEngineTest/1.cancel_can_schedule
[New Thread 0x7ffff1547700 (LWP 11270)]
==================
WARNING: ThreadSanitizer: data race (pid=11268)
Write of size 4 at 0x7fffffffde5c by main thread:
#0 folly::EventBase::runInEventBaseThreadAndWait(folly::Function<void ()>) /home/couchbase/jenkins/workspace/cbdeps-platform-build-old/deps/packages/build/folly/follytsan-prefix/src/follytsan/folly/io/async/EventBase.cpp:661 (ep-engine_ep_unit_tests+0x00000171e04e)
#1 FollyExecutorPool::unregisterTaskable(Taskable&, bool) ../kv_engine/engines/ep/src/folly_executorpool.cc:615 (ep-engine_ep_unit_tests+0x00000062f2b1)
#2 KVBucket::deinitialize() ../kv_engine/engines/ep/src/kv_bucket.cc:489 (ep-engine_ep_unit_tests+0x000000676e45)
#3 EPBucket::deinitialize() ../kv_engine/engines/ep/src/ep_bucket.cc:316 (ep-engine_ep_unit_tests+0x0000005ae8d8)
#4 EventuallyPersistentEngine::~EventuallyPersistentEngine() ../kv_engine/engines/ep/src/ep_engine.cc:6548 (ep-engine_ep_unit_tests+0x0000
View ClangBuildAnalyzer example
/ClangBuildAnalyzer --analyze debug-build-1b.capture
Analyzing build trace from 'debug-build-1b.capture'...
**** Time summary:
Compilation (348 times):
Parsing (frontend): 1573.1 s
Codegen & opts (backend): 317.4 s
**** Files that took longest to parse (compiler frontend):
18032 ms: /Users/dave/repos/couchbase/server/source/build-debug/kv_engine/engines/ep/tests/CMakeFiles/ep-engine_ep_unit_tests.dir/module_tests/evp_store_single_threaded_test.cc.o
16909 ms: /Users/dave/repos/couchbase/server/source/build-debug/kv_engine/engines/ep/tests/CMakeFiles/ep-engine_ep_unit_tests.dir/module_tests/dcp_stream_test.cc.o
View Profiling memcached.md

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
  3. Start workload to be measured
  4. Record profile
    1. x86-64:
      perf record -F 199 -g --call-graph dwarf -p $(pgrep memcached) -- sleep 30
      
View GDB pretty printing of C++ STL.md
  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
View Profling clang build times
https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/
-ftime-trace