Skip to content

Instantly share code, notes, and snippets.

@marioroy
marioroy / README.md
Last active April 26, 2024 05:57
C++ map, set, and vector demonstrations using string_cnt_ub.h (dynamic buffer allocation)

This gist contains five C++ programs, a single header file, and utilities for the Long List is Long (LLiL) challenge.

  1. llil4emh_buf.cc - emhash6::HashMap demonstration
  2. llil4hmap_buf.cc - phmap::flat_hash_set demonstration
  3. llil4map_buf.cc - phmap::parallel_flat_hash_set demonstration
  4. llil4umap_buf.cc - std::unordered_set demonstration
  5. llil4vec_buf.cc - similarly, a std::vector demonstration
  6. string_cnt_ub.h - union std::array with dynamic buffer allocation
  7. gen-files-big.sh - generate 92 big files (total 2.8 GB)
  8. gen-files-long.sh - generate 92 long files (total 5.0 GB)
@marioroy
marioroy / README.md
Last active April 26, 2024 06:03
C++ phmap and vector demonstrations using string_cnt_t

This gist contains two C++ programs, three header files, and utilities for the Long List is Long (LLiL) challenge.

See also, improved variants with dynamic buffer allocation.

  1. llil4map_next.cc - phmap::parallel_flat_hash_map demonstration
  2. llil4vec_next.cc - similarly, a std::vector demonstration
  3. string_cnt.h - original + key length stored with count
  4. string_cnt_f.h - fixed-length-only version
  5. string_cnt_u.h - union std::array
  6. gen-files-big.sh - generate 92 big files (total 2.8 GB)
@marioroy
marioroy / llil4umap.cc
Last active April 26, 2024 06:05
C++ std::unordered_map demonstration
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// llil4umap.cc
// A std::unordered_map demonstration.
// https://perlmonks.org/?node_id=11153406
//
// April 25, 2024
// Based on llil3m.cpp https://perlmonks.com/?node_id=11149482
// Original challenge https://perlmonks.com/?node_id=11147822
// and summary https://perlmonks.com/?node_id=11150293
// Other demonstrations https://perlmonks.com/?node_id=11149907
@marioroy
marioroy / llil4map2.cc
Last active April 26, 2024 06:06
C++ phmap::parallel_flat_hash_map demonstration, vector of pointers
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// llil4map2.cc (vector of pointers)
// A phmap::parallel_flat_hash_map demonstration.
// https://www.perlmonks.com/?node_id=11149643
//
// April 25, 2024
// Based on llil3m.cpp https://perlmonks.com/?node_id=11149482
// Original challenge https://perlmonks.com/?node_id=11147822
// and summary https://perlmonks.com/?node_id=11150293
// Other demonstrations https://perlmonks.com/?node_id=11149907

Latency testing - 4 million pings

  1. Run lagscope receiver.
  2. Run lagscope sender x 4; capture max/avg latencies and time.
  3. Run again with CPU load (count primes); capture algorithm3 time.
Terminal R:  chrt -f 10 lagscope -r
Terminal C:  chrt -i 0 ./algorithm3.pl 1e12   # 2nd run for load testing
Terminal N:  time lagscope -s192.168.1.135 -P

Testing various timer frequencies on Clear Linux with XanMod 6.6.22

  1. Run cyclictest, hackbench, and count primes 1e12, concurrently.
  2. Run algorithm3 and speedometer 2.1 benchmarks, concurrently.
  3. Run hackbench -pTl 40000
  4. Run hackbench -l 10000

Hackbench runs fastest with HZ=750 under load. However, counting primes is noticeably slower. It turns out HZ=800 works well, improving smoothness. On rare occasions, my NVIDIA RTX 3070 fails initialization for one of the

@marioroy
marioroy / bench_xanmod_and_clear_kernels.txt
Created September 22, 2023 14:39
Benchmark XanMod and Clear kernels on Clear Linux
Benchmark XanMod and Clear kernels on Clear Linux, September 22, 2023
Discovery made:
Using XanMod RT, I compared PREEMPT_RT vs PREEMPT_DYNAMIC knobs.
See comparison data at the end of this document.
######################################################################
I tested with sched autogroup enabled in /etc/clr-power-tweaks.conf
@marioroy
marioroy / llil4emh.cc
Last active April 26, 2024 06:08
C++ emhash7::HashMap demonstration
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// llil4emh.cc
// An emhash6::HashMap demonstration.
// https://www.perlmonks.com/?node_id=11149643
//
// April 25, 2024
// Based on llil3m.cpp https://perlmonks.com/?node_id=11149482
// Original challenge https://perlmonks.com/?node_id=11147822
// and summary https://perlmonks.com/?node_id=11150293
// Other demonstrations https://perlmonks.com/?node_id=11149907
@marioroy
marioroy / llil4hmap.cc
Last active April 26, 2024 06:09
C++ phmap::flat_hash_map demonstration
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// llil4hmap.cc
// A phmap::flat_hash_map demonstration.
// https://www.perlmonks.com/?node_id=11149643
//
// April 25, 2024
// Based on llil3m.cpp https://perlmonks.com/?node_id=11149482
// Original challenge https://perlmonks.com/?node_id=11147822
// and summary https://perlmonks.com/?node_id=11150293
// Other demonstrations https://perlmonks.com/?node_id=11149907
@marioroy
marioroy / llil4map.cc
Last active April 26, 2024 06:10
C++ phmap::parallel_flat_hash_map demonstration
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// llil4map.cc
// A phmap::parallel_flat_hash_map demonstration.
// https://www.perlmonks.com/?node_id=11149643
//
// April 25, 2024
// Based on llil3m.cpp https://perlmonks.com/?node_id=11149482
// Original challenge https://perlmonks.com/?node_id=11147822
// and summary https://perlmonks.com/?node_id=11150293
// Other demonstrations https://perlmonks.com/?node_id=11149907