Skip to content

Instantly share code, notes, and snippets.

View MrCroxx's full-sized avatar
🦀
A fresh Rustacean.

Croxx MrCroxx

🦀
A fresh Rustacean.
View GitHub Profile
{
"rust-analyzer.server.extraEnv": {
"RUSTFLAGS": "-Ctarget-feature=+avx2"
},
}
macro_rules! matches {
($expression:expr, $pattern:pat, $ok:expr, $err:expr) => {
match $expression {
$pattern => $ok,
_ => panic!("unwrap_matches unmatched"),
}
};
}
impl<K, V, ER, L, S> Entry<K, V, ER, L, S>
struct HandleKeyAdapter<K, H>(H)
where
K: Key,
H: Handle<K = K>;
impl<K, H> From<H> for HandleKeyAdapter<K, H>
where
K: Key,
H: Handle<K = K>,
{
@MrCroxx
MrCroxx / smt.sh
Last active January 12, 2024 08:34
#!/bin/bash
set -euo pipefail
BASE=$1
SIZE=$2
FILE="${BASE}/fio"
echo "${FILE} will be used for benchmark." | tee benchmark.log
#!/bin/bash
DEV=$1
LOOPS=$2
rm -f iostat.log
for i in `seq 1 ${LOOPS}`; do
date '+%Y-%m-%d %H:%M:%S' | grep -v '^$' | tee -a iostat.log
iostat -x -d ${DEV} | grep -v '^$' | tee -a iostat.log
df -Ph ${DEV} | grep -v '^$' | tee -a iostat.log
@MrCroxx
MrCroxx / bench.sh
Last active January 12, 2024 05:54
#!/bin/bash
set -euo pipefail
BASE=$1
FILE="${BASE}/fio"
echo "${FILE} will be used for benchmark." | tee benchmark.log
SIZE=$(df -Ph ${BASE} | awk 'NR==2 {print $4}')
// Copyright 2024 RisingWave Labs
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// Copyright 2023 MrCroxx
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
#!/bin/bash
read -p 'Enter proxy ip and port (e.g. "127.0.0.1:7890"): ' PROXY
read -s -p "Enter Password for sudo: " SUDOPW
# Configure sudo without password.
echo "Configure sudo without password..."
echo $SUDOPW | sudo -S sed -i 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' /etc/sudoers
# Set needrestart mode to auto.
from bcc import BPF
kallsyms = "/proc/kallsyms"
bpf_text = open("bpf.c").read();
with open(kallsyms) as syms:
ops = ''
for line in syms:
(addr, size, name) = line.rstrip().split(" ", 2)