Skip to content

Instantly share code, notes, and snippets.

View daverigby's full-sized avatar

Dave Rigby daverigby

View GitHub Profile
@daverigby
daverigby / CLion_Ninja.md
Created July 3, 2018 10:00 — forked from nevkontakte/CLion_Ninja.md
Ninja support for CLion IDE

Ninja support for CLion IDE

This script enables Ninja-powered builds in CLion IDE by wrapping around CMake, which it uses. See my blog post for details.

Disclaimer

This script is provided AS IS with no guarantees given or responsibilities taken by the author. This script relies on undocumented features of CLion IDE and may lead to instability of build and/or IDE. Use it on your own risk under WTFPL terms.

# Need to install libasan to be able to run sanitized
# binaries on a machine different to the build machine
# (for example for RPM sanitized packages).
# First need to get the compiler search dirs; then locate
@daverigby
daverigby / checkpoint_iterator1.cpp
Created November 22, 2018 11:13
Checkpoint iterator model using raw reverse iterators (working)
#include <iostream>
#include <vector>
void print(const std::vector<int>& v) {
std::cout << "[";
for (auto& e : v) {
std::cout << e << " ";
}
std::cout << "]\n";
}
@daverigby
daverigby / checkpoint_iterator2.cpp
Last active November 22, 2018 11:26
Checkpoint iterator ideal API - not yet working...
#include <iostream>
#include <list>
#include <vector>
using Container = std::list<int>;
void print(const Container& v) {
std::cout << "[";
for (auto& e : v) {
std::cout << e << " ";
install/bin/erl
1> erlang:load_nif("install/lib/couchdb/erlang/lib/mapreduce-1.0/priv/mapreduce_nif", 0).
#include <functional>
using Raw = int (*)(const char* key, size_t klen,
const char* val, size_t vlen);
using Func = std::function<int(const char* key, size_t klen,
const char* val, size_t vlen)>;
volatile int count = 0;
@daverigby
daverigby / linux_perf_inside_docker
Created February 1, 2019 11:45
Running `linux perf` against a Docker container process
# From the host:
$ nsenter -t <PID as seen by host> /bin/bash
$ perf top / perf report etc.
https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/
-ftime-trace
  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

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: