Skip to content

Instantly share code, notes, and snippets.

View ch-allocator-test.cpp
// Copied from ClickHouse sources
// https://github.com/ClickHouse/ClickHouse/pull/11590
#include <cstdlib>
#include <cstring>
#include <vector>
#include <thread>
#include <iostream>
// - jemalloc:
View getadapteraddresses.cpp
/// Copied from https://docs.microsoft.com/en-us/windows/win32/api/iptypes/ns-iptypes-ip_adapter_addresses_lh
#include <winsock2.h>
#include <iphlpapi.h>
#include <stdio.h>
#pragma comment(lib, "IPHLPAPI.lib")
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
View jemalloc-percpu_arena-check.patch
diff --git a/programs/benchmark/Benchmark.cpp b/programs/benchmark/Benchmark.cpp
index 91c43160e0..fed4823369 100644
--- a/programs/benchmark/Benchmark.cpp
+++ b/programs/benchmark/Benchmark.cpp
@@ -521,6 +521,11 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
{
using boost::program_options::value;
+ const char *val = nullptr;
+ size_t size = sizeof(val);
View libevent-issue-182.c
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <evhttp.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/bufferevent.h>
void http_request_done(struct evhttp_request *req, void *arg){
View kafkalog.py
#!/usr/bin/env -S PYTHONHASHSEED=0 python3
# Highlight kafka debug logs:
#
# kafka debug cgrp,consumer,topic,protocol
#
# Usage example:
#
# kafkalog.py < kafka.log | less -R
View show-create-rewrite.py
#!/usr/bin/env python3
# reformat each SHOW CREATE query for multiline:
# https://github.com/ClickHouse/ClickHouse/pull/10049
import sys
import os
import subprocess
def format_sql(sql, **kwargs):
View le-EV_CLOSED-issue-with-patch-from-issue-984.c
// endless loop for EV_CLOSED with the patch applied from
// https://github.com/libevent/libevent/issues/984
#include <event2/event.h>
#include <unistd.h>
#include <assert.h>
#include <sys/socket.h>
void readcb(int fd, short events, void *arg)
{
View libevent-issue-984.c
// https://github.com/libevent/libevent/issues/984
#include <event2/event.h>
#include <assert.h>
void readcb(int fd, short events, void *arg)
{
printf("%s: fd=%i, events=%hi\n", __func__);
}
void closecb(int fd, short events, void *arg)
View event-active-issue-984.cpp
// https://github.com/libevent/libevent/issues/984
#include <event2/event.h>
#include <event2/event_struct.h>
#include <unistd.h>
#include <cassert>
int main()
{
event_base* base = event_base_new();
View clog.py
#!/usr/bin/env -S PYTHONHASHSEED=0 python3
# pylint: disable=line-too-long
# Highlight (thread, query_id, level) in the clickhouse logs,
# like the server/client does in case stdout is terminal.
#
# Usage example:
#
# clog.py < /var/log/clickhouse-server/clickhouse-server.log | less -R