Skip to content

Instantly share code, notes, and snippets.

Avatar

Domas Mituzas midom

View GitHub Profile
@midom
midom / topwaits.py
Created Jul 2, 2020
stall detector!
View topwaits.py
#!/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 / gist:5342acd489aad11f902e
Last active Aug 29, 2015
localtime() is expensive
View gist:5342acd489aad11f902e
Events: 658K cycles
- 58.75% mysqlbinlog [kernel.kallsyms] [k] _raw_spin_lock ◆
- _raw_spin_lock ▒
- 49.41% dput
@midom
midom / MidpointLruCache.py
Created May 8, 2013
LRU with midpoint insertion (LRU2Q) cache decorator for Python
View MidpointLruCache.py
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):