Skip to content

Instantly share code, notes, and snippets.

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:
  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

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@mbinna
mbinna / effective_modern_cmake.md
Last active April 18, 2024 19:26
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@vasanthk
vasanthk / System Design.md
Last active April 26, 2024 18:05
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@thure
thure / 1.1: Why state machines?.md
Last active February 6, 2023 14:56
SCXML Tutorials

Fundamentals: why state machines?

States. The final frontier. These are the voyages of an enterprising developer. Her eternal mission: to explore strange new techniques, to seek out better ways to engineer for mental models and new design patterns. To boldly go where a few awesome devs have gone before.

So you’ve found our poignant guide to SCXML and surely you’re wondering “Why should I want to go out of my way to use formal state machines?” or something like that. Hopefully this introduction addresses that kind of question.

An example: Nancy’s RPG

The problem

// Require nodes http module
var http = require('http');
// Require a third party mysql module (use "npm install mysql" to install it)
var mysql = require('mysql');
// Create a connection pool
var pool = mysql.createPool({
host: 'localhost',
user: 'username',
@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep=rep1&t