Skip to content

Commit

Permalink
availability numbers, tracing, llvm target abi and features lib problems
Browse files Browse the repository at this point in the history
  • Loading branch information
matu3ba committed Jan 26, 2025
1 parent d10b181 commit 6554cc3
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 27 deletions.
20 changes: 10 additions & 10 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ CompileFlags:
# Add: [-std=c23]
# Add: [-std=c29]

# Core reason for C++17 variant, pair and tuple destructuring, saner template programming
# Core reason for C++20 concepts for sane template programming, consteval (constexpr bad)
# Core reason for C++23 stacktraces, std constexpr-ification, consteval, print
# Core reason for C++26 enum_to_string, string_to_enum, reflection, iostream replacement
# Core reason for C99 portable static integer sizes
# Core reason for C11 generic selection, atomic, tls, threads, alignment
# Core reason for C17 bug fixes and deprecations
# Core reason for C23 attributes, digit separators ', nullptr, empty initializer, embed
# constexpr to prevent VLA + constant obbject init, auto + generic (without C++ compat)
# Core reason for C29 relative sane UTF8 conversion
# Core reasons for C++17 variant, pair and tuple destructuring, saner template programming
# Core reasons for C++20 concepts for sane template programming, consteval (constexpr bad), format
# Core reasons for C++23 stacktraces, std constexpr-ification, consteval, print
# Core reasons for C++26 enum_to_string, string_to_enum, reflection, iostream replacement
# Core reasons for C99 portable static integer sizes
# Core reasons for C11 generic selection, atomic, tls, threads, alignment
# Core reasons for C17 bug fixes and deprecations
# Core reasons for C23 attributes, digit separators ', nullptr, empty initializer, embed
# constexpr to prevent VLA + constant object init, auto + generic (without C++ compat)
# Core reasons for C29 relative sane UTF8 conversion
5 changes: 3 additions & 2 deletions .config/fish/config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ if status is-interactive
# * zdev/zig-bootstrap/master: CMAKE_GENERATOR=Ninja ./build x86_64-linux-musl native
# + enabling checks: -DLLVM_ENABLE_ASSERTIONS=ON \
# + preventing oom: -DLLVM_PARALLEL_LINK_JOBS=1 \
abbr --add -g zbdeb ' ./buildrel/stage3/bin/zig build -p deb -Doptimize=Debug --search-prefix "../../zig-bootstrap/master/out/x86_64-linux-musl-native" --zig-lib-dir lib -Dstatic-llvm'
abbr --add -g zdeb ' ../master/rel/bin/zig build -p deb -Doptimize=Debug --search-prefix "../../zig-bootstrap/master/out/x86_64-linux-musl-native" --zig-lib-dir lib -Dstatic-llvm'
abbr --add -g zbdeb ' ./buildrel/stage3/bin/zig build -p deb -Doptimize=Debug --search-prefix "../../zig-bootstrap/master/out/x86_64-linux-musl-native" --zig-lib-dir lib -Dstatic-llvm -Dno-langref'
abbr --add -g zdeb ' ../master/rel/bin/zig build -p deb -Doptimize=Debug --search-prefix "../../zig-bootstrap/master/out/x86_64-linux-musl-native" --zig-lib-dir lib -Dstatic-llvm -Dno-langref'
abbr --add -g zbllvm ' CMAKE_GENERATOR=Ninja ./build x86_64-linux-musl native'
abbr --add -g zbsrel ' cmake -B buildrel -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="../../zig-bootstrap/master/out/host/" -GNinja && time cmake --build buildrel -j $(nproc)'
abbr --add -g zbrel ' ./buildrel/stage3/bin/zig build -p rel -Doptimize=ReleaseSafe --search-prefix "../../zig-bootstrap/master/out/x86_64-linux-musl-native" --zig-lib-dir lib -Dstatic-llvm -Dno-langref'
Expand Down Expand Up @@ -262,6 +262,7 @@ if status is-interactive
alias schromwlan='firejail --net=wlan0 --private chromium duckduckgo.com'

# rsync
# --info=progress2
abbr --add -g rsync_copy ' rsync -avz --progress -h'
abbr --add -g rsync_move ' rsync -avz --progress -h --remove-source-files'
abbr --add -g rsync_update ' rsync -avzu --progress -h'
Expand Down
5 changes: 4 additions & 1 deletion .config/nvim/lua/my_lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ if not ok_lint then return end
-- uv self update

--==tools
-- uv tool install cppman
-- uv tool install mypy
-- uv tool install ruff
-- uv tool install weasyprint
-- uv tool install yt-dlp

--
-- cppman -c -m true -s cppreference.com
-- man std::thread
-- idea https://github.com/codex-semantics-library/codex

--==installing pixi
Expand Down
4 changes: 4 additions & 0 deletions .config/nvim/lua/my_treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
-- luacheck: globals vim
-- luacheck: no max line length

-- "Syntax highlighting is a waste of an information channel" by Hill Wayne
-- tldr; what to highlight should be switchable since colors have high
-- information density to detect patterns

--====ziggy
--====config

Expand Down
3 changes: 2 additions & 1 deletion .config/shells/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ alias schromwlan='firejail --net=wlan0 --private chromium duckduckgo.com'
#mv adapted-preferences.json ~/.config/google-chrome/Default/Preferences
#
# rsync
# --info=progress2
alias rsync_copy='rsync -avz --progress -h'
alias rsync_move='rsync -avz --progress -h --remove-source-files'
alias rsync_update='rsync -avzu --progress -h'
Expand Down Expand Up @@ -326,4 +327,4 @@ alias sudo='sudo '
# Does not work anymore due to #14708
# zig test exec --zig-lib-dir lib --main-pkg-path lib/std
# Takes ? minutes.
# ./deb/bin/zig build test-standalone -Dskip-release -Dskip-non-native
# ./deb/bin/zig build test-standalone -Dskip-release -Dskip-non-native
5 changes: 3 additions & 2 deletions templates/ci
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@ kill (and wait for) parent process (group).
Observed yesterday on 20240524 Windows in neovim terminal.
MacOs: process becomes orphaned means it never gets cleaned up

https://lewisgaul.co.uk/blog/coding/2022/05/13/cgroups-intro/
cgroups overview
cgroups overview https://lewisgaul.co.uk/blog/coding/2022/05/13/cgroups-intro/
woodpecker https://woodpecker-ci.org https://github.com/woodpecker-ci/woodpecker go
forgejo https://forgejo.org/ https://codeberg.org/forgejo/forgejo go
25 changes: 21 additions & 4 deletions templates/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2847,10 +2847,27 @@ void use_fmt_print();
void use_fmt_print() {
std::print(stdout, "Hello, world!\n");
// std::print(stdout, "%s\n", "Hello, world!"); // %s does not substitute "Hello, world!"
std::string s = std::format("The answer is {}.", 42);
std::print(stdout, "{}\n", s);
(void)s;
}
std::string s1 = std::format("The answer is {}.", 42);
std::print(stdout, "{}\n", s1);

// clangd being showing wrong diagnostics when using c++23
// std::vector<int32_t> v1 = {1, 2, 3};
// std::string s2 = std::format("The other answer is {}.", v1);
// std::print(stdout, "{}\n", s2);
// also works for ranges and containers
// std::print("{::*^5}", std::vector<int>{1, 2, 3});
// std::vector<int> v2 = {1, 2, 3};
// std::print("{}\n", v2);
}

// needs clang 20
// #include <experimental/scope>
// void use_scope_exit();
// void use_scope_exit() {
// void *pMem1 = malloc(100);
// memcpy(pMem1, "abcdef", 5);
// auto guard = std::experimental::scope_exit{[&] { free(pMem1); }};
// }

void use_string_view();
void use_string_view() {
Expand Down
22 changes: 21 additions & 1 deletion templates/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,24 @@
// * often solution is to write macro, so lots of macros pile up and they feel like an entirely
// different language
//
// https://model-checking.github.io/verify-rust-std/
// https://model-checking.github.io/verify-rust-std/

// SHENNANIGANs
// * intentionally racy reads and writes (like for parallel seeded region growing) are not
// expressible currently in Rust
// - Function atomic_load_unordered in nightly, do not use this intrinsic as its not in memory model
// - Function atomic_store_unordered in nightly, do not use this intrinsic as its not in memory model
// - However, according to kprotty "unordered should still be safe to race with"
// pub struct UnorderedAtomic(UnsafeCell<i32>);
// impl UnorderedAtomic {
// pub fn new() -> Self {
// UnorderedAtomic(Default::default())
// }
// pub fn load(&self) -> i32 {
// unsafe { atomic_load_unordered(self.0.get()) }
// }
// pub fn store(&self, i: i32) {
// unsafe { atomic_store_unordered(self.0.get(), i) }
// }
// unsafe fn raw(&self) -> *mut i32 { self.0.get() }
// }
1 change: 1 addition & 0 deletions templates/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const builtin = @import("builtin");
// rigorous perf - https://github.com/ccurtsinger/stabilizer
// libtree(ldd as tree) - https://github.com/haampie/libtree
// typos-cli - https://github.com/crate-ci/typos
// headless browser - https://github.com/lightpanda-io/browser

// Tools windows
// raddebugger - https://github.com/EpicGames/raddebugger
Expand Down
13 changes: 13 additions & 0 deletions templates/distributed_systems
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,16 @@ Network queue implementation without vendor lock-in:
* develop own QUEUE API
* provide adapters for different network work queue protocols

====uptime_downtime
formula:

uptime | downtime | requirement
99.00000 % | 3d 15h 39m |
99.90000 % | 8h 45m 56s | single-region, basic failover
99.99000 % | 52m 15s | multi-region, health checks, automatic failover
99.99900 % | 5m 15s | every layer redundancy, real-time monitoring, active-active deployment
99.99990 % | 31s | chaos engineering, automated canary deployments, sophisticated traffic management
99.99999 % | 3.1536ss | likely direct physical connection of limited participants necessary, static routing (estimation)
99.999999% | 3*10-1s | soft real-time operating kernel of involved systems (estimation)
99.9999999% | 3*10-2s | hard real-time operating kernel of involved systems (estimation)
99.99999999% | 3*10-3s | hard-ware only (estimation very unclear)
4 changes: 3 additions & 1 deletion templates/formal_modeling.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ https://buttondown.email/hillelwayne/archive/nondeterminism-in-formal-specificat
====weak_memory
* best theory overview and consequences "The One-Decade Task: Putting std::atomic in CUDA. - Olivier Giroux - CppCon 2019"
https://www.youtube.com/watch?v=VogqOscJYvk
* only promise theory covers all semantics, but no tooling exists
* "Multicore Semantics: Making Sense of Relaxed Memory"
* C/C++
- sequential
Expand Down Expand Up @@ -183,6 +184,7 @@ https://buttondown.email/hillelwayne/archive/nondeterminism-in-formal-specificat
PNVI-plain, and PVI semantics for C) does not cover all the edge cases from pointers
https://www.cl.cam.ac.uk/~pes20/cerberus/clarifying-provenance-v4.html#q3.-can-one-make-a-usable-pointer-via-casts-to-intptr_t-and-back
- 8. build system parallelization relies on "Jobserver Implementation" protocol
* only reliable behavior is to close file descriptors and related process owned resources on process termination
* Pain point: protocol relies on a process manually releasing resources
before it dies, rather than relying on kernel-managed resources that are
automatically released when the process dies
Expand Down Expand Up @@ -363,7 +365,7 @@ https://buttondown.email/hillelwayne/archive/nondeterminism-in-formal-specificat
* kv cache etc
* idea: spikes are like synaptic connection strengths and represent output of neuron
* spikes express a sequence over time
- 18. TLA+ as only feasibe system to formally verifiy non-deterministic
- 18. TLA+ as only feasibe system to formally verify non-deterministic
parallelism, states and changes over time via temporal logic
* https://www.learntla.com/
* TODO
Expand Down
6 changes: 4 additions & 2 deletions templates/gdb
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,15 @@ if that does not work
if that does not work
- debugging inside qemu runner
if that does not work:
- reduce the problem + printf debugging of all intermediat artefacts
- reduce the problem + printf debugging of all intermediate artefacts
* we have no way to introspect the problem, so we can only try to modify
the system behavior

gdbserver localhost:2000 ./exec
target remote localhost:2000

Howto: GDB Remote Serial Protocol Writing a RSP Server Jeremy Bennett Embecosm
https://www.embecosm.com/appnotes/ean4/embecosm-howto-rsp-server-ean4-issue-2.html#id3074175

-fno-stack-protector
-static
Expand Down Expand Up @@ -373,4 +375,4 @@ Free ones https://zweilosec.gitbook.io/hackers-rest/, https://www.ired.team/
Manually mapping Windows dll https://www.youtube.com/watch?v=qzZTXcBu3cE

debugger tricks
* keep line numbers correct (+ while editing) https://nullprogram.com/blog/2024/01/28/
* keep line numbers correct (+ while editing) https://nullprogram.com/blog/2024/01/28/
15 changes: 15 additions & 0 deletions templates/linux
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ journalctl -n 200
auditd (access monitoring framework)
bpftrace (general tracing solution to create + run ebpf programs)
idea: usage with monitoring, is bcc necessary?
almost complete tracing solution for Linux, no attaching possible:
* https://github.com/namhyung/uftrace

====trace
choices https://www.brendangregg.com/blog/2015-07-08/choosing-a-linux-tracer.html

query trace language for kernel and user space Linux:
* https://sourceware.org/systemtap/examples/keyword-index.html
* example https://stackoverflow.com/questions/46783960/systemtap-simple-userspace-example-function-tracing-ubuntu
* usability issues
- SystemTap doesn't (usually) work on kernels newer than the systemtap release due to internal kernel API changes
- access to your program state is very painful with bpf
- older kernels can't get the kernels headers and debuginfo installed
- SystemTap dyninst runtime requires restarting the target so it can LD_PRELOAD
- must configure everything like in dtrace https://blogs.oracle.com/linux/post/dtrace-for-the-application-developer-counting-function-calls

cd /sys/kernel/debug/tracing
echo 'sig==9' > events/signal/signal_generate/filter
Expand Down
18 changes: 17 additions & 1 deletion templates/llvm
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Online correctness validation of transformations:
templates/llvoOnline correctness validation of transformations:
https://alive2.llvm.org/ce/

Goal: LLVM Design is for a "simple IR" to allow simple and efficient optimizations.
Problem1: LLVM requires user to handle target features and target abi, which
is very error-prone; even though to reduce work, having one implementation would
offset costs.
Problem2: No way, in general, to retain all the high level information in LLVM without
flavoring the LLVM IR with target info (C type system and every other lang).
Solution0: Make it a lib.
Solution1: Make a (0BSD) target feature library with exhaustive tests.
Solution2: Make a (0BSD) target abi library with exhaustive tests.
Problem1.1 and Problem2.1: Design without compromising Goal ("simple IR")?
-> indirection + callbacks necessary
-> no fine-tuning feasible without exhaustive tests, logical model, validators
and formal verification etc
https://discourse.llvm.org/t/passing-structs-to-c-functions/83938/9
https://github.com/lifting-bits/anvill

Instructions to bring up cmake and llvm on very old systems with cmake.
Note: Using `-DLLVM_ENABLE_PROJECTS="all" \` might break, so use minimal necessary output.
libc and compiler-rt are other common options, but also not necessary.
Expand Down
3 changes: 3 additions & 0 deletions templates/parallel_programming.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,6 @@ Simple
* "Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms" by Maged M. Michael and Michael L. Scott.
https://github.com/Qarterd/Honeycomb/blob/master/src/common/Honey/Thread/LockFree/Queue.h
https://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html

"FIFO can be Better than LRU: the Power of Lazy Promotion and Quick Demotion" by Yang et al.
LP-FIFO (e.g., FIFO-Reinsertion)/CLOCK N’th Chance (2 bits) can be faster, more scalable and have better miss ration than LRU.
5 changes: 4 additions & 1 deletion templates/tooling
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ front-end tools | perf
tracing frameworks | ftrace, perf_event, eBPF
Back-end instrumentation | tracepoints, kprobes, uprobes
source: https://wiki.st.com/stm32mpu/wiki/Linux_tracing,_monitoring_and_debugging
bpf-based
* https://github.com/grafana/beyla
* https://github.com/gojue/ecapture https://docs.kubeshark.co/en/encrypted_traffic

Embedded (mutli-partition swapping)
Embedded (multi-partition swapping)
https://sbabic.github.io/swupdate/swupdate.html

Non-programming tools:
Expand Down
7 changes: 6 additions & 1 deletion templates/win
Original file line number Diff line number Diff line change
Expand Up @@ -733,4 +733,9 @@ Tools to inspect Windows registry
* regdump
* https://github.com/strozfriedberg/notatin
* https://github.com/ColinFinck/nt-hive
* https://github.com/libguestfs/hivex
* https://github.com/libguestfs/hivex

====trace
* dtrace
bcdedit /set dtrace on
idea: example usage https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dtrace

0 comments on commit 6554cc3

Please sign in to comment.