Skip to content

Instantly share code, notes, and snippets.

View markpapadakis's full-sized avatar
💭
Seeking Knowledge 24x7

Mark Papadakis markpapadakis

💭
Seeking Knowledge 24x7
View GitHub Profile
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/file.h>
#include <unistd.h>
#include <linux/limits.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
# CloudDS
2048 requests in sequence - percentiles captured in an HDRHistogram
All CloudDS caching options disabled.
Cluster Size: 7
Replication Factor: 3
Row size in Columns: 10
Row size/payload: 2.5KBs
Column Family size in rows: 4MM
Cluster configuration: half of those 7 nodes commodity HW with 8GB RAM, other blade-class nodes with 4GB of RAM. Gigabit link for interconnect.
Cluster in active/heavy use by many other production services(not idle).
// A simple LUT backed index for faster binary search, with LUT partition encoding
// A bloom filter can be attached to it, for when you have many, many values - though in practice
// it is rarely needed, especially if the bits(resolution) is over 16
//
// You need (1 << bits) * sizeof(T::key) for the lut, e.g if T::key is uint32_t, for a 16bits LUT, that's
// 262k. Increasing resolution results in higher lookup efficiency, reducing it results in lower memory requirements
template<typename T>
static __attribute__((always_inline)) constexpr T MSB(const T n, const uint8_t span)
{
//
// Dropping exta 0 bits starting from the most significant bit in order to create a better LUT for binary search
// This is a practical example of this idea
//
// You can e.g serialize (LUT, totalValues) and when you need to perform a binary search, consult the LUT first.
// This should do wonders, in particular, when each lookup requires a disk seek(even on SSDs)
//
// You may want to consider multiple LUTs(or skiplists), if the distribution of values is such that the majority of values
// are mapped to the same index. This shoudl be trivial to accomplish, and should help mitigate distribution related issues.
// Ref: http://iaroslavski.narod.ru/quicksort/DualPivotQuicksort.pdf
template<typename T>
void DualPivotQuickSort(T *lo, T *hi, const std::function<int32_t(const T &, const T&)> &cmp)
{
auto *const hiMinus1 = hi - 1;
if (hi - lo < 3)
{
if (hi != lo && cmp(*lo, *hiMinus1) > 0)
{
template<typename T>
static const T *BinarySearch(const T *const first, const T *const last, const T value, std::function<int32_t(const T&, const T&)> cmp)
{
const auto n = last - first;
int32_t top = n - 1, btm = 0;
while (btm <= top)
{
const auto mid = (btm & top) + ((btm ^ top) >> 1);
const auto p = first + mid;

I and many others do not get any Wikipedia or web search results on Spotlight, neither in Yosemite, nor in iOS 8.0+. Apparently, it's because Apple doesn't want us to get any results.

Try

curl "https://api.smoot.apple.com/search?q=Apple&locale=en-US&calendar=gregorian&key=andromeda" -H "X-Apple-UI-Scale: 1.000000"   -A "(OS X 14A389) Spotlight/916" -H "Accept-Language: en-us"

Chances are you are getting:

As I outlined in this overseer post, we aggregate all crashes so that we know about any serious issue the moment it happens, and we have some consumers that deal with them individually, one of them notifying us on Slack, others logging them, etc.

Because everyone can build and run a consumer, here's one that I 'll personally use: For each abort event (system.apps.abort), a key comprised of the source code file and line where it happened (filename:line) is created.

A lookup on a CloudDS 'table' checks if we have encountered that before; if not, then it's set there and a nice Wunderlist task, complete with stacktrace frames, node name, and more, is created and placed in a special list, via RPC.

@markpapadakis
markpapadakis / enum_dyn_syms.cpp
Last active August 29, 2015 14:06
Scans an ELF DLL/DSO looking for globally exported syms/objects. Useful for App Servers, game engines, etc
#include <elf.h>
// Scans an ELF DLL/DSO looking for globally epxorted symbols/objects of type object or function
// Very useful for e.g application servers or games where you don't really want to pre-define those functions/objects in e.g a list
// and instead you can define them in any file that makes up the module. That way you will scan them and identfiy what you need and load it later
//
// e.g
// EnumDynSyms("AppServerModules/search.dso", [](const char *const name, const uint8_t type)
// {
if (const auto cnt = rowsToWarmup.Size())
{
int fd = open(finalPath, O_RDONLY|O_LARGEFILE);
const row *const all = rowsToWarmup.Values();
const auto shift = __builtin_ffs(getpagesize()) - 1;
volatile uint32_t ac = 0;
const auto before = Timings::Microseconds::Tick();
if (unlikely(fd == -1))
{