Skip to content

Instantly share code, notes, and snippets.

@CAFxX
CAFxX / golang_minimize_allocations.md
Last active May 8, 2024 12:51
Minimize allocations in Go

📂 Minimize allocations in Go

A collection of tips for when you need to minimize the number of allocations in your Go programs.

Use the go profiler to identify which parts of your program are responsible for most allocations.

⚠️ Never apply these tricks blindly (i.e. without measuring the actual performance benefit/impact). Most of these tricks cause a tradeoff between reducing memory allocations and other aspects (including e.g. higher peak memory usage, higher CPU usage, lower maintainability, higher probability of introducing subtle bugs). Only apply these tricks if the tradeoff in every specfic case is globally positive.

Protobuf

@leoh0
leoh0 / CVE-2019-5736.md
Last active December 30, 2019 00:23
CVE-2019-5736 poc 와 해결방법을 정리 했습니다.

CVE-2019-5736

설명

이 취약점은 악의적인 사용자가 컨테이너(runc를 사용하는 docker 등)를 사용해서 호스트 시스템의 runc 바이너리를 변조하여 root 억세스를 가능하게 합니다. 자세한내용은 redhat을 참고하시면 좋습니다.

POC

@ByungSunBae
ByungSunBae / greedy_algorithm.go
Last active January 24, 2019 01:30
탐욕알고리즘(greedy algorithm)으로 풀어보는 (간단한) 음식 선택하기 - Golang version
// From : https://www.edwith.org/datascience/lecture/33888/
// edwith에서 한글자막을 달아놓은 MIT의 Data Science 강좌중 첫번째 챕터입니다.
// 위 링크에서 파이썬 버전의 코드를 받아보실 수 있습니다.
// 칼로리가 제한될 때, 음식을 선택하는 문제를 탐욕 알고리즘으로 푸는 문제입니다.
// 파이썬 코드를 Golang으로 변환했습니다.
package main
import (
"flag"
<html>
<head></head>
<body>
<a href="{{ . }}">Kakao Login</a>
</body>
</html>
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jboner
jboner / latency.txt
Last active May 8, 2024 03:00
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
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