Skip to content

Instantly share code, notes, and snippets.

View midom's full-sized avatar

Domas Mituzas midom

View GitHub Profile
@midom
midom / topwaits.py
Created July 2, 2020 17:11
stall detector!
#!/usr/bin/env bcc-py
#
# topwaits Show longest off-cpu waits per-stack
#
# Copyright 2019 Facebook, Inc.
# Copyright 2016 Netflix, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
#
# 13-Jan-2016 Brendan Gregg Wrote offcpu profiler
# 27-Nov-2019 Domas Mituzas Gutted most of profiling part and left stall detector
@midom
midom / MidpointLruCache.py
Created May 8, 2013 20:43
LRU with midpoint insertion (LRU2Q) cache decorator for Python
class MidpointLruCache:
def __init__(self, size, oldpercentage):
self.size = size
self.oldsize = size * oldpercentage / 100
self.youngsize = size * (100 - oldpercentage) / 100
self.youngitems = collections.OrderedDict()
self.olditems = collections.OrderedDict()
def __call__(self, func):
@midom
midom / gist:5342acd489aad11f902e
Last active August 29, 2015 14:01
localtime() is expensive
Events: 658K cycles
- 58.75% mysqlbinlog [kernel.kallsyms] [k] _raw_spin_lock ◆
- _raw_spin_lock ▒
- 49.41% dput