This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// https://github.com/aosp-mirror/platform_bionic/blob/master/benchmarks/atomic_benchmark.cpp | |
/* | |
* Copyright (C) 2017 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select version(); | |
-- ┌─version()───┐ | |
-- │ 20.3.15.133 │ | |
-- └─────────────┘ | |
create table ranges_data engine=Memory() as select number key, number value from numbers(100); | |
create dictionary default.ranges_dict (key UInt64, value UInt64 default 1) primary key key source(clickhouse(host '127.0.0.1' port 9000 table 'ranges_data' db 'default' user 'default' password '')) lifetime(0) layout(cache(size_in_cells 100)); | |
create table dist as system.one engine=Distributed('test_cluster_two_shards', system, one, dictGetUInt64('default.ranges_dict', 'value', toUInt64(dummy))); | |
SELECT * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# XXX: cannot use expect since we need two clients | |
# XXX: requires bash 4.4+ | |
function assert() | |
{ | |
if ! "$@"; then | |
echo "'$*' failed" >&2 | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gist for showing that rand() with global lock is slower ~60x times | |
// (came to this for librdkafa random partitioning with producer per group, and eventually program has ~1200 threads) | |
// | |
// $ g++ -DRAND -o rand -O3 -pthread rand.cpp | |
// $ g++ -DRAND_R -o rand_r -O3 -pthread rand.cpp | |
// | |
// $ time ./rand | |
// | |
// real 0m2.336s | |
// user 0m2.685s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist to check possible issues with MADV_DONTNEED | |
// For example it does not supported by qemu user | |
// There is a patch for this [1], but it hasn't been applied. | |
// [1]: https://lists.gnu.org/archive/html/qemu-devel/2018-08/msg05422.html | |
#include <sys/mman.h> | |
#include <stdio.h> | |
#include <stddef.h> | |
#include <assert.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2020-09-22 00:48:35 01502_jemalloc_percpu_arena: [ FAIL ] 7.43 sec. - return code 66 | |
2020-09-22 00:48:35 ================== | |
2020-09-22 00:48:35 WARNING: ThreadSanitizer: data race (pid=384) | |
2020-09-22 00:48:35 Write of size 8 at 0x7b1000008ff8 by main thread (mutexes: write M1432): | |
2020-09-22 00:48:35 #0 operator delete(void*, unsigned long) <null> (clickhouse+0x8085f1e) | |
2020-09-22 00:48:35 #1 Poco::Logger::~Logger() /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:39:1 (clickhouse+0x14dc78ce) | |
2020-09-22 00:48:35 #2 non-virtual thunk to Poco::Logger::~Logger() /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp (clickhouse+0x14dc78ce) | |
2020-09-22 00:48:35 #3 Poco::RefCountedObject::release() const /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/RefCountedObject.h:82:24 (clickhouse+0x14dcb797) | |
2020-09-22 00:48:35 #4 Poco::Logger::shutdown() /build/obj-x86_64-linux-gnu/../contrib/poco/Found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reproducer for percpu_arena jemalloc issue [1]. | |
* Requires debug jemalloc (w/o NDEBUG to include assert()s) | |
* | |
* [1]: https://github.com/jemalloc/jemalloc/pull/1676 | |
* | |
* $ gcc -g3 -o /tmp/sched /tmp/sched.c | |
* $ MALLOC_CONF=percpu_arena:percpu LD_PRELOAD=jemalloc/build/lib/libjemalloc.so taskset --cpu-list 3 /tmp/sched | |
* <jemalloc>: ../src/jemalloc.c:321: Failed assertion: "ind <= narenas_total_get()" | |
* Aborted (core dumped) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_exist() | |
{ | |
local needle="$1" | |
shift | |
local i | |
for i; do | |
[ "$needle" = "$i" ] && return 0 || continue | |
done | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copied from ClickHouse sources | |
// https://github.com/ClickHouse/ClickHouse/pull/11590 | |
#include <cstdlib> | |
#include <cstring> | |
#include <vector> | |
#include <thread> | |
#include <iostream> | |
// - jemalloc: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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)) |