Skip to content

Instantly share code, notes, and snippets.

@patricksuo
patricksuo / coreclr-usdt.patch
Created October 5, 2017 23:38 — forked from goldshtn/coreclr-usdt.patch
.NET Core (CoreCLR) patch for emitting USDT probes
diff --git a/src/scripts/genXplatLttng.py b/src/scripts/genXplatLttng.py
index bacf034..3d40d77 100644
--- a/src/scripts/genXplatLttng.py
+++ b/src/scripts/genXplatLttng.py
@@ -407,8 +407,25 @@ def generateLttngTpProvider(providerName, eventNodes, allTemplates):
for eventNode in eventNodes:
eventName = eventNode.getAttribute('symbol')
templateName = eventNode.getAttribute('template')
+
+ template = allTemplates[templateName] if templateName else None
@patricksuo
patricksuo / dotnet-mapgen-v2.py
Created October 6, 2017 17:02 — forked from goldshtn/dotnet-mapgen-v2.py
dotnet-mapgen: generates map files for crossgen-compiled assemblies, and merges them into the main perf map file
#!/usr/bin/env python
#
# USAGE: dotnet-mapgen [-h] {generate,merge} PID
#
# In generate mode, this tool reads the /tmp/perfinfo-PID.map file generated
# by the CLR when running with COMPlus_PerfMapEnabled=1, and finds all load
# events for managed assemblies. For each managed assembly found in this way,
# the tool runs crossgen to generate a symbol mapping file (akin to debuginfo).
#
# In merge mode, this tool finds the load address of each managed assembly in
@patricksuo
patricksuo / latency.txt
Created October 9, 2017 02:25 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static SemaphoreSlim mSema1 = new SemaphoreSlim(1);
static SemaphoreSlim mSema2 = new SemaphoreSlim(0);
func BuyHandler(buyRequest BuyRequest) {
for i:=0; i<MaxRetry; i++ {
needRetry := func() (retry bool) {
defer func() {
if err := recover(); err != nil {
if _, isTxConflic := err.(ErrTransactionConflic); isTxConflic {
retry = true;
}
package reflectimport ( "runtime"
"sync"
"unsafe"
)
type Caller struct {
v Value
//readonly cache
numIn int

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

@patricksuo
patricksuo / empty.s
Last active November 12, 2018 03:38
PID
// gist 不支持空文件
@patricksuo
patricksuo / solarized_for_xshell.xcs
Created August 14, 2018 14:35 — forked from solicomo/solarized_for_xshell.xcs
Solarized Light/Dark Theme of XShell
[Names]
count=2
name1=Solarized Dark
name0=Solarized Light
[Solarized Light]
text(bold)=586e75
magenta(bold)=6c71c4
text=657b83
white(bold)=fdf6e3
green=859900
using System;
using System.Text;
using Consul;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using System.Threading;