blog

Personal blog
git clone git://git.laack.co/blog.git
Log | Files | Refs

commit 00e40bbb192c88c009b189d265e3b69018fa004d
parent 41b154f75699e33d4312fb304f8dd6a0c8ab4836
Author: Andrew Laack <andrew@laack.co>
Date:   Tue,  6 Oct 2026 21:27:46 -0500

Added graphic alt-text, more work on stuff, building html for wip

Co-authored-by: Vim

Diffstat:
Mposts/entries/pygame-vs-raylib.md | 2+-
Mposts/gemini/feed.xml | 7+++++--
Mposts/site/feed.xml | 7+++++--
Mposts/site/pygame-vs-raylib.html | 5++++-
Aposts/site_wip/a-brief-history-of-version-control.html | 37+++++++++++++++++++++++++++++++++++++
Aposts/site_wip/a-gemini-browser.html | 757+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/advertising.html | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/ai-and-meta-work.html | 40++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/ai-makes-programming-boring-for-me.html | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/all-roads-lead-to-gemtext.html | 37+++++++++++++++++++++++++++++++++++++
Aposts/site_wip/are-llms-useful.html | 40++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/basic-software-profiling-part-1-cpu-usage.html | 315+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/complexity-facilitates-opression.html | 38++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/default-cracked.html | 37+++++++++++++++++++++++++++++++++++++
Aposts/site_wip/dissatisfaction.html | 37+++++++++++++++++++++++++++++++++++++
Aposts/site_wip/do-tools-actually-matter.html | 39+++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/encrypted-messaging.html | 39+++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/greyscale-shader.html | 36++++++++++++++++++++++++++++++++++++
Aposts/site_wip/how-i-learn.html | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/how-to-choose-software.html | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/ideal-note-taking.html | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/interesting-tests-ive-written.html | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/just-because-youre-right-doesnt-mean-it-matters.html | 47+++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/lets-make-all-software-faster.html | 39+++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/my-definition-of-good-software.html | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/my-favorite-piece-of-software.html | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/my-ideal-vcs.html | 46++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/rent-seeking-software.html | 43+++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/should-i-be-using-llms-for-learning.html | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/the-best-privacy-browser.html | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/the-big-three-privacy-search-engines.html | 44++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/the-case-against-verification.html | 42++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/the-legality-of-summarization.html | 38++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/tracking-lifts.html | 155+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/what-i-want-from-a-vcs.html | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/what-is-a-lockscreen.html | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/what-makes-good-software.html | 37+++++++++++++++++++++++++++++++++++++
Aposts/site_wip/why-people-build-spyware.html | 48++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/why-us-software-sucks.html | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/wikipedia-and-truth-on-the-internet.html | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/will-inference-costs-come-down.html | 42++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/yes-software-does-get-completed.html | 37+++++++++++++++++++++++++++++++++++++
Aposts/site_wip/you-are-being-tricked.html | 39+++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/your-arrogance-is-their-bet.html | 39+++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/your-gemini-search-engine.html | 38++++++++++++++++++++++++++++++++++++++
Dposts/wip/(how-to)-profile-your-software.md | 326-------------------------------------------------------------------------------
Aposts/wip/basic-software-profiling-part-1-cpu-usage.md | 304+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ascripts/convert_wip.sh | 5+++++
48 files changed, 3523 insertions(+), 332 deletions(-)

diff --git a/posts/entries/pygame-vs-raylib.md b/posts/entries/pygame-vs-raylib.md @@ -4,7 +4,7 @@ I implemented [Prim's algorithm](https://cp-algorithms.com/graph/mst_prim.html) to create a MST of a graph in Python. I also created a visualization of it, shown below. -![](videos/prim.mkv) +![Prim's algorithm visualization](videos/prim.mkv) (This graph has 250 vertices and 1,000 edges. The source code used to generate this visualization can be found [here](https://git.laack.co/blog/file/python/pygame-vs-raylib/prim.py.html)) diff --git a/posts/gemini/feed.xml b/posts/gemini/feed.xml @@ -7,13 +7,16 @@ <language>en-us</language> <managingEditor>andrew@laack.co</managingEditor> <webMaster>andrew@laack.co</webMaster> -<lastBuildDate>Sat, 03 Oct 2026 10:41:44 -0500</lastBuildDate> +<lastBuildDate>Tue, 06 Oct 2026 21:25:54 -0500</lastBuildDate> <atom:link href="gemini://blog.laack.co/feed.xml" rel="self" type="application/rss+xml"/> <item> <title><![CDATA[PyGame vs. Raylib]]></title> <link>gemini://blog.laack.co/pygame-vs-raylib.gmi</link> <description><![CDATA[<p>I implemented <a href="https://cp-algorithms.com/graph/mst_prim.gmi">Prim’s algorithm</a> to create a MST of a graph in Python. I also created a visualization of it, shown below.</p> -<p><video src="videos/prim.mkv" controls=""><a href="videos/prim.mkv">Video</a></video></p> +<figure> +<video src="videos/prim.mkv" controls=""><a href="videos/prim.mkv">Prim’s algorithm visualization</a></video> +<figcaption aria-hidden="true">Prim’s algorithm visualization</figcaption> +</figure> <p>(This graph has 250 vertices and 1,000 edges. The source code used to generate this visualization can be found <a href="https://git.laack.co/blog/file/python/pygame-vs-raylib/prim.py.gmi">here</a>)</p> <p>Prim’s algorithm is worth understanding (albeit out of scope), and the problem it solves is finding the set of edges that minimizes the sum of their weights while guaranteeing there is exactly one path between any two vertices in the connected, weighted, undirected graph. In the case of my implementation, the weight of each edge was its length.</p> <p>As it relates to the animation, the following two things should be apparent:</p> diff --git a/posts/site/feed.xml b/posts/site/feed.xml @@ -7,13 +7,16 @@ <language>en-us</language> <managingEditor>andrew@laack.co</managingEditor> <webMaster>andrew@laack.co</webMaster> -<lastBuildDate>Sat, 03 Oct 2026 10:41:44 -0500</lastBuildDate> +<lastBuildDate>Tue, 06 Oct 2026 21:25:54 -0500</lastBuildDate> <atom:link href="https://blog.laack.co/feed.xml" rel="self" type="application/rss+xml"/> <item> <title><![CDATA[PyGame vs. Raylib]]></title> <link>https://blog.laack.co/pygame-vs-raylib.html</link> <description><![CDATA[<p>I implemented <a href="https://cp-algorithms.com/graph/mst_prim.html">Prim’s algorithm</a> to create a MST of a graph in Python. I also created a visualization of it, shown below.</p> -<p><video src="videos/prim.mkv" controls=""><a href="videos/prim.mkv">Video</a></video></p> +<figure> +<video src="videos/prim.mkv" controls=""><a href="videos/prim.mkv">Prim’s algorithm visualization</a></video> +<figcaption aria-hidden="true">Prim’s algorithm visualization</figcaption> +</figure> <p>(This graph has 250 vertices and 1,000 edges. The source code used to generate this visualization can be found <a href="https://git.laack.co/blog/file/python/pygame-vs-raylib/prim.py.html">here</a>)</p> <p>Prim’s algorithm is worth understanding (albeit out of scope), and the problem it solves is finding the set of edges that minimizes the sum of their weights while guaranteeing there is exactly one path between any two vertices in the connected, weighted, undirected graph. In the case of my implementation, the weight of each edge was its length.</p> <p>As it relates to the animation, the following two things should be apparent:</p> diff --git a/posts/site/pygame-vs-raylib.html b/posts/site/pygame-vs-raylib.html @@ -102,7 +102,10 @@ <h1 id="pygame-vs.-raylib">PyGame vs. Raylib</h1> <h2 id="date-20260920">Date: 2026/09/20</h2> <p>I implemented <a href="https://cp-algorithms.com/graph/mst_prim.html">Prim’s algorithm</a> to create a MST of a graph in Python. I also created a visualization of it, shown below.</p> -<p><video src="videos/prim.mkv" controls=""><a href="videos/prim.mkv">Video</a></video></p> +<figure> +<video src="videos/prim.mkv" controls=""><a href="videos/prim.mkv">Prim’s algorithm visualization</a></video> +<figcaption aria-hidden="true">Prim’s algorithm visualization</figcaption> +</figure> <p>(This graph has 250 vertices and 1,000 edges. The source code used to generate this visualization can be found <a href="https://git.laack.co/blog/file/python/pygame-vs-raylib/prim.py.html">here</a>)</p> <p>Prim’s algorithm is worth understanding (albeit out of scope), and the problem it solves is finding the set of edges that minimizes the sum of their weights while guaranteeing there is exactly one path between any two vertices in the connected, weighted, undirected graph. In the case of my implementation, the weight of each edge was its length.</p> <p>As it relates to the animation, the following two things should be apparent:</p> diff --git a/posts/site_wip/a-brief-history-of-version-control.html b/posts/site_wip/a-brief-history-of-version-control.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>a-brief-history-of-version-control</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="a-brief-history-of-version-control">A Brief History of Version Control</h1> +<p>git, svn, cvs, darcs, pijul</p> +</body> +</html> diff --git a/posts/site_wip/a-gemini-browser.html b/posts/site_wip/a-gemini-browser.html @@ -0,0 +1,757 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>a-gemini-browser</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="a-gemini-browser-in-c">A Gemini Browser (in C++)</h1> +<p>I’ve written gemini browsers before, but I never saw them through to completion; a silly proposition for such a simple task, but prior iterations lacked the structure necessary to see the project through. An earlier attempt, in Go, ended with a 500 line main file, some tests, and a bunch of weird state management. This time I’ll be using TDD, a sensible object hierarchy, and general sensibilities.</p> +<h2 id="ncurses">Ncurses</h2> +<p>Ncurses is a great dependency (I know, dependency, yuck). It just makes sense without imposing stupid constraints. I can bind all of the keys I care about in the way I want, what’s missing? Honestly, pretty much nothing (except maybe not great support for unicode, but I don’t care about unicode, ascii ftw!!!).</p> +<h2 id="issues">Issues</h2> +<p>Redirects – it’s rather hard to find normal redirects. There’s a stress test redirect thing, but that redirects to a redirect loop or smt.</p> +<h2 id="process">Process</h2> +<ul> +<li>First you consider requirements</li> +<li>Then you make choices</li> +<li>Then you refine your choices</li> +</ul> +<p>When you don’t first consider requirements, you make choices like using Go or some other GC language that’s slow as fuck, and you end up with something that has performance characteristics of amfora.</p> +<p>So, here they are:</p> +<ul> +<li>Every user intereaction must happen exceptionally fast</li> +<li>Memory overhead should be limited whenever possible, but it should not be traded off for performance</li> +<li>Minimize the complexity of the codebase</li> +</ul> +<p>To minimize complexity, I chose to only depend on a few select, semi-sane, dependencies. One was <code>uri</code> for parsing URIs. This is a smallish header file, feels acceptable. Ncurses was another. It’s not very magical and just does the thing you expect it to do without being constraining in any ways I’d find irritating, unlike many TUI frameworks which have notions of how things should be laid out on screen, and how keybindings and such should work – I wanted full control over keybindings, and this was what put me off of things like tview which I’ve found to be annoying to make my own keybindings with, so might as well just do my own painting with ncurses.</p> +<h3 id="implementation">Implementation</h3> +<hr /> +<p>TESTING:</p> +<ul> +<li>gcov + lcov +<ul> +<li>gnu coverage, lcov for viz</li> +</ul></li> +<li>coverage based testing at commit ff1badfc22b1fde35a018cf6406ec51b4a31fab1 +<ul> +<li>~/personal-files/blog/foreseen-coverage-3</li> +<li>this was after refactoring from the getch looping model for the ‘o’ menu -&gt; taking inputs to the function +<ul> +<li>and returnning instead of blocking.</li> +</ul></li> +<li>realized I’m not covering backspace / escape cases which are relatively important so added those.</li> +<li>after fixing: +<ul> +<li>(render.cpp:182-212)</li> +<li>417a0a3c157bb7849fd1562603b2d655d017245b</li> +<li>still have cols = 0 so will want to address that with passable cols and rows +<ul> +<li>will help to make sure small sizes don’t have weird issues I used to have with crashing +<ul> +<li>/ infinite loops</li> +</ul></li> +</ul></li> +</ul></li> +</ul></li> +<li>refactored link follow redirecting +<ul> +<li>y / n support from input arg</li> +<li>after: +<ul> +<li>~/personal-files/blog/foreseen-coverage-5</li> +<li>6254ff6de2feeee86d3b83d87d121694e6fddb4d</li> +<li>render coverage: +<ul> +<li>39.8 % 244 97 54.5 % 11 6</li> +</ul></li> +<li>(then added no branch coverage)</li> +</ul></li> +</ul></li> +<li>refactored user input for status 1X +<ul> +<li>965b9203d358a9ff145334ffc8b3c38aab7def5a</li> +<li>~/personal-files/blog/foreseen-coverage-5</li> +<li>render coverage: +<ul> +<li>55.2 % 248 137 63.6 % 11 7</li> +</ul></li> +</ul></li> +<li>added the ability to edit a page in editor +<ul> +<li>2dce468fc819fcfe39561f195dba111434edf828</li> +<li>~/personal-files/blog/foreseen-coverage-6</li> +<li>render coverage: +<ul> +<li>60.7 % 257 156 63.6 % 11 7</li> +</ul></li> +</ul></li> +</ul> +<hr /> +<p>it’s a bit slow though. Let’s get benchmarks for that.</p> +<ul> +<li>refactored main loop to accept rows and cols as parameters so I can test that. +<ul> +<li>commit: e357bcbbb0cc23129c1719ae38819fb4a46c0c1e</li> +<li>testing: +<ul> +<li>-O0</li> +<li>we find these results with a small file:</li> +</ul></li> +</ul></li> +</ul> +<pre><code>benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +All line types - X: 8 Y: 8 100 1 34.6794 ms + 314.314 us 308.421 us 324.578 us + 38.7483 us 26.394 us 65.5161 us + +All line types - X: 8 Y: 9 100 1 28.572 ms + 284.577 us 277.58 us 297.826 us + 47.7262 us 29.1738 us 74.4475 us + +All line types - X: 9 Y: 8 100 1 27.5064 ms + 277.78 us 273.851 us 287.784 us + 29.7422 us 14.0369 us 60.6527 us + +All line types - X: 9 Y: 9 100 1 27.3251 ms + 296.212 us 288.637 us 307.774 us + 46.9271 us 34.7786 us 69.0629 us</code></pre> +<p>the above samples are from commit 59cbaf1b90f4dfde5db35d4c9d474497f9d72e11</p> +<p>These are all very fast; to be expected considering we are just reading a file from disk and rendering it. I’m not too concerned about optimizing that, but the case I noticed was slow before was scrolling for large files.</p> +<p>let’s evaluate that.</p> +<p>So we write some code to generate a string of 100_000 chars size, write it to a file, and see how that goes.</p> +<p>(the string has and ’ ’ along with al num):</p> +<p>100 up, 100 down, 100x100 screen size</p> +<pre><code> +benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +100k character file, load, scroll +down 100x, scroll up 100x with +100x100 emulated terminal size 100 1 6.97173 m + 4.94128 s 4.79944 s 5.08459 s + 726.364 ms 660.585 ms 805.704 ms</code></pre> +<p>why so slow?</p> +<p>well, we are currently calling breaklines every time we call draw, which is a lot. this means we go through each line each time, using our accumulation logic to breaklines to fit on screen. That logic isn’t perfect; but why call it more often than needed instead of focusing on making that bit fast right now.</p> +<p>We really only need to break in two cases:</p> +<ol type="1"> +<li>content of page changes</li> +<li>screensize changes</li> +</ol> +<p>so we handle screensize changes by checking if current cols != prior and same for lines.</p> +<p>To check if screen content has changed, we could do a != check, but that’d be basically the same issue as we’d have to scan each line each time. As such, we should have another boolean to track this too.</p> +<p>we can just set it as true whenever we might be performing a state transiation between screens. after we update the textrender vector, we then set rebreak to true.</p> +<p>(the times it might change are f,b,reload, open (site, link))</p> +<p>admittedly this make the software a bit more complex, but it is much, much faster for large files.</p> +<pre><code>benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +100k character file, load, scroll +down 100x, scroll up 100x with +100x100 emulated terminal size 100 1 1.97092 m + 1.28874 s 1.23349 s 1.35405 s + 304.981 ms 258.005 ms 373.63 ms</code></pre> +<p>commit - 70af9dfaf9afa5586109d2c21ba3df7f5f86118f</p> +<p>alright, so that’s 3.53x faster, not terrible for what is a fairly small file.</p> +<p>what’s taking so much time now?</p> +<p>let’s consult perf!</p> +<ul> +<li>96.47% 0.02% bench1.out bench1.out [.] draw(DrawState&amp;) ▒</li> +<li>96.42% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::CompleteType&lt;std::remove_reference&lt;std::remove_cv&lt;std▒</li> +<li>96.42% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::CompleteType&lt;std::remove_reference&lt;std::remove_cv&lt;std▒</li> +<li>96.42% 0.00% bench1.out bench1.out [.] std::vector&lt;std::chrono::duration&lt;double, std::ratio&lt;1l, 1000000000l&gt; &gt;, std::a▒</li> +<li>96.42% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Benchmark::run<std::chrono::_V2::steady_clock>()::{lambda()#2▒</li> +<li>96.42% 0.00% bench1.out bench1.out [.] std::enable_if&lt;std::is_same&lt;std::chrono::_V2::steady_clock, std::chrono::_V2::s▒</li> +<li>96.42% 0.01% bench1.out bench1.out [.] Catch::Benchmark::Detail::run_plan_default(Catch::Benchmark::ExecutionPlan cons▒</li> +<li>93.85% 9.90% bench1.out bench1.out [.] sanitizeCharactersToDraw(std::vector&lt;std::pair&lt;std::__cxx11::basic_string&lt;char,▒</li> +<li>79.51% 3.76% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>75.41% 9.64% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>30.58% 7.91% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>21.26% 11.97% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>16.02% 6.88% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>14.83% 4.53% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>14.53% 7.35% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>10.56% 7.06% bench1.out bench1.out [.] unsigned long const&amp; std::min<unsigned long>(unsigned long const&amp;, unsigned lon▒</li> +<li>8.21% 1.18% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>8.02% 5.48% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>6.70% 3.32% bench1.out bench1.out [.] std::__cxx11::basic_string&lt;char, std::char_traits<char>, std::allocator<char> &gt;▒</li> +<li>6.69% 5.21% bench1.out bench1.out [.] std::char_traits<char>::assign(char&amp;, char const&amp;) ▒</li> +</ul> +<p>I see; so draw is quite slow. specifically though, we notice most of the time is spent in</p> +<ul> +<li>93.85% 9.90% bench1.out bench1.out [.] sanitizeCharactersToDraw(std::vector&lt;std::pair&lt;std::__cxx11::basic_string&lt;char,▒</li> +</ul> +<p>why is that? well, it goes through the entire list (again), to pull out … characters and do substitiutions as necessary. seems rather useless to be here in all honesty.</p> +<p>we can do this as part of the mustrerender process, let’s do that. instead.</p> +<p>now we get:</p> +<pre><code>benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +100k character file, load, scroll +down 100x, scroll up 100x with +100x100 emulated terminal size 100 1 2.06189 s + 20.9672 ms 20.8873 ms 21.0798 ms + 480.389 us 369.924 us 666.694 us</code></pre> +<p>We went from a mean of 4.94128s to 20.9672 ms, we find this is:</p> +<p>4941.28ms -&gt; 20.9672ms</p> +<p>4941.28ms / 20.9672ms = 235.66713724293183x faster.</p> +<p>, and this is for a small(ish) file where we are actually doing a relatively small amount of up / down movements. I would’ve used larger files, but it was originally so slow that I couldn’t.</p> +<hr /> +<p>ohh yeah, and we also got a shitload more coverage:</p> +<ul> +<li>render.cpp +<ul> +<li>84.7 % 275 233 81.8 % 11 9</li> +</ul></li> +</ul> +<p>Lines: 91.0 % 2067 1882 Test Date: 2026-09-30 15:12:43 Functions: 94.7 % 190 180</p> +<hr /> +<p>ok, let’s go with 10,000,000 for evaluation to see how the perf stacks up with 1k down, 1k up</p> +<pre><code> +benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +10m character file, load, scroll +down 1000x, scroll up 1000x with +100x100 emulated terminal size 100 1 5.08277 m + 2.7127 s 2.61997 s 2.81432 s + 494.032 ms 444.661 ms 544.078 ms +</code></pre> +<pre><code>+ 99.99% 0.00% bench1.out bench1.out [.] CATCH2_INTERNAL_TEST_0() ++ 99.85% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Benchmark&amp; Catch::Benchmark::Benchmark::operator= ++ 99.85% 0.00% bench1.out bench1.out [.] void Catch::Benchmark::Benchmark::run&lt;std::chrono::_V2::steady_cloc ++ 98.82% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::BenchmarkFunction::model&lt;CATCH2_INTERNAL_ ++ 98.82% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::BenchmarkFunction::model&lt;CATCH2_INTERNAL_ ++ 98.82% 0.00% bench1.out bench1.out [.] void Catch::Benchmark::Chronometer::measure&lt;CATCH2_INTERNAL_TEST_0( ++ 98.82% 0.00% bench1.out bench1.out [.] void Catch::Benchmark::Chronometer::measure&lt;CATCH2_INTERNAL_TEST_0( ++ 98.82% 0.00% bench1.out bench1.out [.] std::enable_if&lt;std::is_same&lt;void, decltype ({parm#1}({parm#2}...))&gt; ++ 98.82% 0.00% bench1.out bench1.out [.] CATCH2_INTERNAL_TEST_0()::{lambda(int)#1}::operator()(int) const ++ 97.91% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::CompleteType&lt;std::remove_reference&lt;std::r ++ 97.91% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::CompleteType&lt;std::remove_reference&lt;std::r ++ 97.91% 0.00% bench1.out bench1.out [.] std::vector&lt;std::chrono::duration&lt;double, std::ratio&lt;1l, 1000000000 ++ 97.91% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Benchmark::run&lt;std::chrono::_V2::steady_clock&gt;(): ++ 97.91% 0.00% bench1.out bench1.out [.] std::enable_if&lt;std::is_same&lt;std::chrono::_V2::steady_clock, std::ch ++ 97.91% 0.00% bench1.out bench1.out [.] Catch::Benchmark::Detail::run_plan_default(Catch::Benchmark::Execut ++ 97.72% 0.00% bench1.out bench1.out [.] mainLoop(DrawState&amp;, Browser&amp;, int, int, int) ++ 80.38% 0.06% bench1.out bench1.out [.] draw(DrawState&amp;) ++ 61.79% 4.26% bench1.out bench1.out [.] breakLines(std::vector&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, s</code></pre> +<p>so… we are still spending a ton of time on these larger files on breaklines. there’s also ~20% time spent on other stuff related to drawing, most of which appears to be</p> +<pre><code>+ 17.20% 0.00% bench1.out bench1.out [.] Browser::goToSite(std::__cxx11::basic_string&lt;char, std::char_traits ++ 17.20% 0.00% bench1.out bench1.out [.] tryVisitSite(DrawState&amp;, Browser&amp;, std::__cxx11::basic_string&lt;char, ++ 16.94% 0.12% bench1.out bench1.out [.] Browser::toLines(Site*) ++ 14.64% 1.57% bench1.out bench1.out [.] sanitizeCharactersToDraw(std::vector&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, TextRender&gt;, std</code></pre> +<p>so quite a bit of time is spent on 1) toLines, mostly sanitize characters 2) breakLines</p> +<p>alright, let’s focus on breaklines first.</p> +<pre><code>std::vector&lt;std::pair&lt;std::string, TextRender&gt;&gt; breakLines(std::vector&lt;std::pair&lt;std::string, TextRender&gt;&gt;&amp; strLs, int width, int cols) { + + std::vector&lt;std::pair&lt;std::string, TextRender&gt;&gt; res {}; + + int leftPadAmount = std::max(0, (cols - width) / 2); + std::string leftPadStr (leftPadAmount, &#39; &#39;); + + if(width &lt;= 0) { + return res; + } + + for(std::size_t i = 0; i &lt; strLs.size(); ++i) { + + std::string cstr = strLs[i].first; + + if(!strLs[i].second.shouldFold) { + int limit = cols - leftPadAmount; + int w = 0; + std::size_t end = 0; + while(end &lt; cstr.size()) { + int len = std::min(u8len(cstr[end]), (int)(cstr.size() - end)); + int cw = u8width(cstr, end, len); + if(w + cw &gt; limit) { + break; + } + w += cw; + end += len; + } + cstr = cstr.substr(0, end); // otherwise there&#39;s some funkiness at the end due to how ncurses renders stuff. + res.push_back(std::pair&lt;std::string,TextRender&gt; {leftPadStr + cstr, strLs[i].second}); + continue; + } + + std::string current = &quot;&quot;; + int curWidth = 0; + int lastSpace = -1; + int lastSpaceWidth = 0; + + for(int x = 0; x &lt; (int)cstr.size(); ) { + if(cstr[x] == &#39;\n&#39;) { + res.push_back(std::pair&lt;std::string,TextRender&gt; {leftPadStr + current, strLs[i].second}); + current = &quot;&quot;; + curWidth = 0; + lastSpace = -1; + ++x; + continue; + } + + int len = std::min(u8len(cstr[x]), (int)cstr.size() - x); + int w = u8width(cstr, x, len); + + if(w &gt; 0 &amp;&amp; curWidth &gt; 0 &amp;&amp; curWidth + w &gt; width) { + + std::string toPush = current; + + if(lastSpace != -1) { + toPush = current.substr(0,lastSpace+1); + current = current.substr(lastSpace+1); + curWidth = curWidth - lastSpaceWidth; + } else { + current = &quot;&quot;; + curWidth = 0; + } + + res.push_back(std::pair&lt;std::string,TextRender&gt; {leftPadStr + toPush,strLs[i].second}); + lastSpace = -1; + } + + current.append(cstr, x, len); + curWidth += w; + if(cstr[x] == &#39; &#39;) { + lastSpace = current.size() - 1; + lastSpaceWidth = curWidth; + } + x += len; + } + if(current.size() &gt; 0) { + res.push_back(std::pair&lt;std::string,TextRender&gt; {leftPadStr + current,strLs[i].second}); + current = &quot;&quot;; + } + } + + return res; +} +</code></pre> +<p>so we take in strls then break and transfer lines into a new list to return it. We do want this to be the case because strLs may be broken again with different cols so it must be const.</p> +<p>first thing we can do is allocate the proper amount of space for res up front. After we do our width check, we know have a lower bound of the size of the strLs, so let’s use that.</p> +<pre><code>res.reserve(strLs.size());</code></pre> +<p>we can also make cstr a const reference and then cut down on a few allocations during the !shouldFold branch:</p> +<pre><code>const std::string&amp; cstr = strLs[i].first;</code></pre> +<p>if we look at sanitize characters,</p> +<p>```void sanitizeCharactersToDraw(std::vector&lt;std::pair&lt;std::string, TextRender&gt;&gt;&amp; strLs) { for(std::size_t i = 0; i &lt; strLs.size(); ++i) {</p> +<pre><code> std::string&amp; s = strLs[i].first; + + std::string out; + for (int c: s) + if (c == &#39;\r&#39; || c == &#39;\v&#39; || c == &#39;\b&#39; || c == &#39;\f&#39; || c == &#39;\a&#39; || c == &#39;\0&#39;) { + continue; + } else if (c == &#39;\t&#39;) { + out += &quot; &quot;; // \t is a larger character and fucks with breaklines. + } else { + out += c; + } + + strLs[i].first = out; +} +return;</code></pre> +<p>}</p> +<pre><code> +the main issue with this is += has the same reseze issue as our vector did before. + +since most characters won&#39;t be special, it&#39;s relatively safe to just do: +</code></pre> +<p>out.reserve(s.size());</p> +<pre><code> +there&#39;s other stuff that can be done to make each invocation faster, but I wonder if threads could help with this because this is quite parallelizable. + + +let&#39;s first do this with the sanitize characters to draw because this is quite safe given that it&#39;s operating on a vector to permute it instead of constructing a vector to return. +</code></pre> +<p>void operate(std::vector&lt;std::pair&lt;std::string, TextRender&gt;&gt;&amp; strLs, std::size_t idxStart, std::size_t idxStop) { for(std::size_t i = idxStart; i &lt; idxStop; ++i) { std::string&amp; s = strLs[i].first; std::string out; out.reserve(s.size());</p> +<pre><code> for (int c : s) + if (c == &#39;\r&#39; || c == &#39;\v&#39; || c == &#39;\b&#39; || c == &#39;\f&#39; || c == &#39;\a&#39; || c == &#39;\0&#39;) { + continue; + } else if (c == &#39;\t&#39;) { + out += &quot; &quot;; // \t is a larger character and fucks with breaklines. + } else { + out += c; + } + + strLs[i].first = std::move(out); +} +return;</code></pre> +<p>}</p> +<p>void sanitizeCharactersToDraw(std::vector&lt;std::pair&lt;std::string, TextRender&gt;&gt;&amp; strLs) { std::vector<std::thread> threads{};</p> +<pre><code>if(strLs.size() &gt; 100) { + for(int i = 0; i &lt; 10; ++i) { + threads.emplace_back(&amp;operate, std::ref(strLs), i*strLs.size() / 10, (i+1)*strLs.size() / 10); + } + for(auto&amp; t: threads) { + t.join(); + } +} else { + operate(strLs, 0, strLs.size()); +}</code></pre> +<p>}</p> +<pre><code> + +before threading, with allocation changes: +</code></pre> +<p>benchmark name samples iterations est run time mean low mean high mean std dev low std dev high std dev ——————————————————————————- 10m character file, load, scroll down 1000x, scroll up 1000x with 100x100 emulated terminal size 100 1 4.32557 m 3.374 s 3.26604 s 3.49725 s 589.504 ms 512.778 ms 697.531 ms</p> +<pre><code> + +after threading: +</code></pre> +<p>10m character file, load, scroll down 1000x, scroll up 1000x with 100x100 emulated terminal size 100 1 4.27891 m 3.35466 s 3.24084 s 3.4761 s 598.993 ms 541.664 ms 678.83 ms</p> +<pre><code> +ok, probably not worth the added complexity for dubious returns, albeit without calibration for thread count. + +the other issue with this is the cache friendliness of it. we are storing a pair for each element when we really just care about the strings. this would require sizeable refactors to fix, but is perhps worth considering in the future as it&#39;s a more data-oriented-design thing. + + +--- + +let&#39;s stop and compare olevels for this now. I&#39;ll run each a few times. + + +we perform 5 iterations of reading in the same file, doing the parsing, doing the 1000 down, 1000 up on O0 per iteation. This means we are averaging across iterations where a single iteration is itself 5 iterations of loading the file and doing the movement: + +-O0 +</code></pre> +<p>benchmark name samples iterations est run time mean low mean high mean std dev low std dev high std dev ——————————————————————————- 5 passes per iteration, 10m character file, load, scroll down 1000x, scroll up 1000x with 100x100 emulated terminal size 100 1 22.7922 m 17.3735 s 16.9738 s 17.7704 s 2.03698 s 1.86856 s 2.23307 s</p> +<pre><code> +-Ofast +</code></pre> +<p>benchmark name samples iterations est run time mean low mean high mean std dev low std dev high std dev ——————————————————————————- 5 passes per iteration, 10m character file, load, scroll down 1000x, scroll up 1000x with 100x100 emulated terminal size 100 1 4.61931 m 2.43228 s 2.35738 s 2.51318 s 399.998 ms 356.84 ms 449.1 ms</p> +<pre><code> +ohh yeah. + +--- + +memory overhead is rather large though... + +1064kb + + +amfora: + +baseline: 24MB + +andrew@deepthought:~$ du -s 1.1MB.gmi +1064 1.1MB.gmi + +1.1MB file: 49MB + +delta: 25MB + +foreseen: + +baseline: 9.2MB + +1.1MB file: 25MB + +delta: 15.8MB + +most of their optimization appears to come from showing txt where they don&#39;t have character coloring, it seems, which really cuts down on memory usage, but when they have gemtext, even without any formatting, it&#39;s still way bigger. + + +amfora ~2MB file: 77MB +amfora ~2MB file: 39MB + +get a recording of this shit because it&#39;s fucking pathetic. + +we&#39;re also storing ~3 copies of the page: + +- Site - this is in cache, containing the body + header +- Preformatted - before breaking lines +- Postformatted - after breaking lines + - we really want these unless we compute these in realtime because + - screen size changes can unbreak lines which would add additional computation + - instead of just throwing out prior and starting fresh without folding back lines. + +we could put the cache on disk. We could also try compressing the cache. + +the former would make cache accesses way slower; like we see when reading files from disk. + +--- + +--- + +at what point did we accept that software could just be dogshit slow all the fucking time? I tried using amfora recently and it was absolutely fucking unbearable. Are you serious? You can&#39;t open a file bigger than 2MB? Why the fuck not? I have 16, goddamn, gigabytes of memory? Oh, I see, because you are a performance leach and it would be **fucking** embarrassing if I could open larger files because it would show how utterly fucking stupid you are. + +Let&#39;s get to it. + +--- + +Ok, so let&#39;s figure out why amfora is slow; is it stupid algorithmic choices or a stupid language choice? + +--- + +so amfora is slow to open, taking a few frames, but this is inconsequential relative to the time taken to open any file of reasonable size (&gt;1MB), so what&#39;s that about? + +I mean, it compiles quickly which is nice, but it&#39;s slow as fuck otherwise. + +--- + +1.3M count.gmi + +perf record -g amfora ~/count.gmi + +these are just 262180 lines of number that are &lt;=5 digits long. + +I was going to update the code to stop it when the file had finished rendering, whatever codepath would do that, but it took so fucking long it didn&#39;t even matter. + +&gt; + 99.23% 0.00% amfora amfora [.] 0x0000555f1b69fb41 ◆ +&gt; + 68.33% 0.00% amfora amfora [.] 0x0000555f1b69db67 ▒ +&gt; + 61.24% 0.00% amfora amfora [.] 0x0000555f1b646b45 ▒ +&gt; + 60.22% 0.00% amfora amfora [.] 0x0000555f1b646d69 ▒ +&gt; + 54.87% 0.00% amfora amfora [.] 0x0000555f1b64abf4 ▒ + +good thing perf works great with go binaries! /s + +maybe this is unfair; if I did the same for a real PL like haskell I&#39;d get poor results too so I guess that&#39;s fine. + +--- + +go build -ldflags=&quot;-compressdwarf=false&quot; -o amfora . +perf record -F 99 -g -o perf.data ./amfora ~/count.gmi + +git clone https://github.com/brendangregg/FlameGraph +perf script -i perf.data | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl &gt; amfora.svg + +/home/andrew/gitRepos/blog/posts/site/images/amfora-no-info.svg + +--- + +ok so there is some information here I guess. + +so we see 70% of the time is spent by the GC, nice. + +we then spend 25% of our computation opening the file and rendering it. + +This is mostly: + +RenderGemini: runtime.concatstring3 + +file:///home/andrew/gitRepos/blog/posts/site/images/amfora-no-info.svg?s=render&amp;x=25.9&amp;y=613 (render gemini) + +concat string 3: + +24.34% of the 25.11% that is the rendergemini function. + +14.88% is runtime.memmove and 9.42% is runtime.concatstrings + +--- + +In the go code this is: + +renderer/renderer.go + +per their code comment: +</code></pre> +<p>// RenderGemini converts text/gemini into a cview displayable format. // It also returns a slice of link URLs. // // width is the number of columns to wrap to. // leftMargin is the number of blank spaces to prepend to each line. // // proxied is whether the request is through the gemini:// scheme. // If it’s not a gemini:// page, set this to true.</p> +<pre><code> +the line that takes most of the actual computational time is this: + +</code></pre> +<p>buf += strings.TrimSuffix(lines[i], “) +””</p> +<pre><code> +what in the actual fuck? + +This is a O(n^2) op.... we yoink the current line and append it to the current line. + +now in c++ this wouldn&#39;t be, but since go strings are immutable, this copies... them... every... single... fucking... time. + +The fix is actually relatively simple: use a stringbuilder. + +the delta of 22 lines on my part (there is no pr for this because the project is unmaintained) is: + +go build -ldflags=&quot;-compressdwarf=false&quot; -o amfora . +perf record -F 99 -g -o perf.data ./amfora ~/count.gmi + +perf script -i perf.data | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl &gt; amfora.svg + +~/gitRepos/blog/posts/site/images/amfora-fixed.svg + +--- + +sorry, flamegraphs are relative: + +from perf: + +(before): Event count (approx.): 262436801339 +(after): Event count (approx.): 5188060667 + +&gt;&gt;&gt; 5188060667 / 262436801339 +0.019768800109319945 + +this now costs 1.98% of what it did before.... or in other words this is 50x fucking faster for &quot;large&quot; files of this shape. + +https://github.com/makew0rld/amfora/pull/370 + +Ok, I did create a pr for this. + +--- + +I see, so it&#39;s not necessarily go that&#39;s slow, and it&#39;s not necessarily the GC, it&#39;s these stupid fucking language decisions that bite people in the fucking ass. + +Perhaps an aside, but it&#39;s so fucking annoying when imperative languages impose stupid fucking rules for no damn good reason. Like, it&#39;s not mathematically more correct to not mutate state in GO? In declarative / fp langs, I get it, in go? Fuck you. + +Admittedly, c++ has some annoying copy stuff where you&#39;ll accidentally copy stuff too often, passing by value some big ass thing, but I guess that&#39;s just something you learn, and in c++ you kinda can because that shit&#39;s fast as fuck, but like learn not to ig. + +--- + +alright, let&#39;s stick to our own lane; no reason to compare with utter dogshit software. + +--- + +perf record -g foreseen + +(normal usage for a few minutes) + +--- + +ok, so ~/gitRepos/blog/posts/site/images/foreseen-flamegraph-bench.svg?x=410.3&amp;y=325 + +33.77% of time is spent in u8width. + +this is -Ofast + +Of the time spent in breaklines (45.61%), this makes up the bulk of it. + +int u8width(const std::string&amp; s, std::size_t i, int len) { + std::mbstate_t st {}; + wchar_t wc; + if (std::mbrtowc(&amp;wc, s.data() + i, len, &amp;st) != (std::size_t)len) { + return 1; + } + int w = wcwidth(wc); + if (w &lt; 0) { + return 0; + } + return w; +} + + +well this is kinda overkill because it&#39;s probably the case that most of our text is ascii, esp, in our benchmarks, but also in the realworld. So let&#39;s special case handle ascii first. + +```cpp +unsigned char c = static_cast&lt;unsigned char&gt;(s[i]); +if (len == 1 &amp;&amp; c &lt; 0x80) { + return (c &gt;= 0x20 &amp;&amp; c != 0x7F) ? 1 : 0; +}</code></pre> +<p>(we call sanitize characters to draw before this so there are no tabs)</p> +<p>that’s it, then the rest remains for utf-8. This skips the libc calls for ascii, while still being consistent, taking advantage of domain knowledge here to short-circuit computations.</p> +<p>(after change)</p> +<pre><code> +------------------------------------------------------------------------------- +Benchmarking huge file scrolling +------------------------------------------------------------------------------- +benchmarking/render-bench.cpp:25 +............................................................................... + +benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +5 passes per iteration, 10m +character file, load, scroll down +1000x, scroll up 1000x with 100x100 +emulated terminal size 100 1 2.09376 m + 1.29688 s 1.28467 s 1.3104 s + 65.4397 ms 57.5482 ms 75.5631 ms +</code></pre> +<p>~/gitRepos/blog/posts/site/images/flamegraph-shortcircuit.svg</p> +<p>relative to before, we now spend only 21.84% of our time in this function, and only 3.27% of our total time is spent in the utf-8 encoding block, more than 10x less in terms of the portion of our time spent in that function. that is across all benchmarks though (actually that was just small file + huge file), but just the huge file rendering we had this before:</p> +<p>(before change)</p> +<pre><code>benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +5 passes per iteration, 10m +character file, load, scroll down +1000x, scroll up 1000x with 100x100 +emulated terminal size 100 1 2.92848 m + 1.91088 s 1.8952 s 1.93021 s + 89.0951 ms 71.0092 ms 113.665 ms</code></pre> +<p>so the one little, tiny, change for shortcircuiting ascii to avoid libc gives us ~47% better performance, on average… one tiny function. all of a flamegraph and a little domain consideration.</p> +<hr /> +<p>can it be faster? obviously, but at this point I’m pleased for large file usage and such.</p> +<hr /> +<p>productionizing:</p> +<ol type="1"> +<li>config files +<ul> +<li>utter dog shit</li> +</ul></li> +<li>editing source code</li> +<li>cli arguments</li> +<li>env varaibles +<ul> +<li>utter dog shit, it’s so fucking annoying putting utter bullshit into my .bashrc / other sourced files</li> +</ul></li> +</ol> +<p>editing source code + cli arguments it is.</p> +<hr /> +<p>I should’ve realized I was doing too many copies with cstr before:</p> +<pre><code>std::string cp = cstr; +current.append(cp, x, len);</code></pre> +<p>with that perf is this:</p> +<pre><code> +benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +5 passes per iteration, 10m +character file, load, scroll down +1000x, scroll up 1000x with 100x100 +emulated terminal size 100 1 2.02098 m + 1.27579 s 1.26486 s 1.29325 s + 69.2992 ms 48.4834 ms 101.668 ms +</code></pre> +<p>after fix:</p> +<pre><code>benchmark name samples iterations est run time + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +5 passes per iteration, 10m +character file, load, scroll down +1000x, scroll up 1000x with 100x100 +emulated terminal size 100 1 1.18109 m + 742.083 ms 736.293 ms 749.936 ms + 34.263 ms 25.8876 ms 47.0647 ms</code></pre> +<p>dang.</p> +<hr /> +<p>argparse next</p> +<p>done, easily.</p> +<hr /> +</body> +</html> diff --git a/posts/site_wip/advertising.html b/posts/site_wip/advertising.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>advertising</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="advertising">Advertising</h1> +<p>I have always been detrimentally contrarian. This likely stems from a desire to feel in control of my choices, and by rejecting the propositions of others, it feels like I have control of my choices. Perhaps this may be incorrect, and I may be over-analyzing the root cause, but in any case, I have always been excessively contrarian, even now.</p> +<h2 id="the-benefits-of-advertising">The Benefits of Advertising</h2> +<p>“If you build it, he will come” is an appealing notion, but likely not applicable to most endeavors. To some extent, gaining adoption of things requires telling others about them, not simply building it. Advertising is a common way to tell people about things. Advertising things that will help others is a win-win.</p> +<h2 id="the-failures-of-advertising">The Failures of Advertising</h2> +<p>I do agree it is a win-win if the builder and consumer both benefit from advertising, but this is so infrequently the case that I generally don’t agree with it in practice. I used to see many advertisements, and they frequently felt like the following:</p> +<blockquote> +<p>You <em>need</em> to buy this thing because xyz.</p> +</blockquote> +<blockquote> +<p>We are the only people who can give this to you</p> +</blockquote> +<blockquote> +<p>You are incapable of doing this yourself</p> +</blockquote> +<p>This comes from reading between the lines, but no one advertises things that can be easily done by individuals. This is to say, advertisements sell solutions to your helplessness by first showing how helpless you are, and then telling you about their potion to solve it.</p> +<p>Advertisements are not frequently this forward, but notionally this is what they are doing. Being excessively contrarian, having others tell me I am helpless and need them to do something for me is irritating. Sometimes my initial reaction is to do what they are selling without their help, but when so many advertisements are thrown my way, I would get stretched too thin.</p> +<h2 id="saying-no">Saying No</h2> +<p>I have stopped doing most things that will result in me being advertised to. There are certain things I believe are unavoidable advertisements, but in these cases I generally do two things:</p> +<ol type="1"> +<li>Be exceptionally rude about the advertisement</li> +<li>Ensure I never support the advertiser in any way in the future</li> +</ol> +<p>The first is difficult because culturally advertising is acceptable, and confrontations are hard, but I so vehemently disagree with advertisements that I will express my discontentment face to face.</p> +<p>The second is rather simple; any time you see an advertisement that you didn’t implicitly agree to see by using an ad supported service or something akin, make a note of the company and ensure you never support them again. I was in San Francisco and saw Mullvad VPN advertisements on buses. At the time, I used their VPN because I perceived it as the best, and perhaps on merit it is still, but after seeing the advertisement I made sure to never use their services again, or recommend their services. If you want to use a VPN, use IVPN, Proton has similarly problematic advertising, or setup your own as I have taken to doing.</p> +<h2 id="acceptable-and-unacceptable-advertisements">Acceptable and Unacceptable Advertisements</h2> +<p>Acceptable:</p> +<ul> +<li>TV</li> +<li>Subscriptions that state they are ad supported</li> +<li>Services that are free with ads</li> +</ul> +<p>Unacceptable:</p> +<ul> +<li>Advertisements visible to individuals who aren’t partaking in a service supported by ads +<ul> +<li>Billboards are not supporting roadways and by using the public roadways, I haven’t consented to being advertised to</li> +</ul></li> +<li>Public services +<ul> +<li>Busses in SF are covered in advertisements, and simply walking on sidewalks forces them into my view</li> +<li>SFO airport has lots of advertisements; that’s a public place that has no business having random advertisements. If I see ads on a plane that’s one thing (presumably my ticket was cheaper to facilitate that), but not in the airport itself</li> +<li>Random events +<ul> +<li>This is slightly different, but if I’m at something like defcon I’d expect not to be gratuitiously advertised to during talks. Stations are par for the course, but talks should be devoid of ulterior motationvs; be a human.</li> +</ul></li> +</ul></li> +</ul> +<p>A form of advertisement that bothers me is self-advertisement. People whoring theselves out to find a job at so-called “networking events” are one thing (simply don’t attend), but if I’m at dinner with a group, I expect everyone to live in the moment, not try to get a job out of me or get me to work with / for them. It’s annoying. I noticed this is especially bad in San Francisco, mostly because of how little I’ve noticed these annoyances in the midwest.</p> +</body> +</html> diff --git a/posts/site_wip/ai-and-meta-work.html b/posts/site_wip/ai-and-meta-work.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>ai-and-meta-work</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="ai-and-meta-work">AI and Meta-Work</h1> +<p>https://news.ycombinator.com/item?id=47517539</p> +<blockquote> +<p>The last 10 years in the software industry in particular seems full of meta-work. New frameworks, new tools, new virtualization layers, new distributed systems, new dev tooling, new org charts. Ultimately so we can build… what exactly? Are these necessary to build what we actually need? Or are they necessary to prop up an unsustainable industry by inventing new jobs?</p> +</blockquote> +</body> +</html> diff --git a/posts/site_wip/ai-makes-programming-boring-for-me.html b/posts/site_wip/ai-makes-programming-boring-for-me.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>ai-makes-programming-boring-for-me</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="ai-makes-programming-boring-for-me">AI Makes Programming Boring For Me</h1> +<h2 id="date-20251016">Date: 2025/10/16</h2> +<h2 id="why-i-started-programming">Why I Started Programming</h2> +<p>I think I started programming because of social influences, namely my father, but very quickly I learned of its beauty. In my first programming courses I became infatuated by telling a computer what to do and it doing exactly what was specified. Very quickly one learns their specifications often differ from what they intended, but a few keystrokes and the program will start behaving as anticipated. This is not the case with AI.</p> +<p>A problematic part of programming with AI is non-determinism. When I make mistakes programming I can track down the source of the mis-specification and solve it. When AI makes a mistake, it often feels like a guessing game, waiting for the AI to find the issue and resolve it, often getting stuck and becoming unable to do so. This process is frustrating to me, but the process of debugging is not. Debugging is clear and logical, you trace the flow of information and find where there is a mismatch between reality and expectations, you then fix it. It’s nice, it’s simple, it feels guaranteed that given enough time, the issue will be resolved. I haven’t found this to be the case with AI.</p> +<h2 id="drudgery">Drudgery</h2> +<p>I’ve heard the argument that using AI to program allows one to be more productive by delegating away the drudgery of programming, but the drudgery is often useful.</p> +<ol type="1"> +<li>Drudgery results in better code +<ul> +<li>I can ask an AI to change the text in 1,000 magic strings in a few seconds. If I can do this, what’s the point of consolidating them into one constant? It’s very minimal, but the second a human goes into that codebase, they will be in a world of pain. Additionally, this issue is not solved by simply always using AI, AI will often update a few of these strings, enough to make the operator think the problem is fixed, but not actually fix the issue. This causes even more confusion, degrading the quality of the codebase and the resulting program.</li> +</ul></li> +<li>Drudgery breeds automation +<ul> +<li>Similar to the prior, if I can ask an AI to build my application and upload it to an SFTP server, what’s the point in automating the process? I can just ask it to do this every time. I think this is more common than we’d like to admit, and a big issue with this is that current AI systems are non-deterministic. Each time you ask the AI to upload to the server, there is a non-zero chance it will mess something up. This chance can be substantially decreased by automating the process, it can also be sped up by doing this, and it will likely be cheaper (tokens aren’t free).</li> +</ul></li> +</ol> +<h2 id="you-dont-know-what-you-dont-know">You Don’t Know What You Don’t Know</h2> +<p>I know a non-zero amount about cryptography, FUSE, and networking. If Cryptomator didn’t exist, I could build something similar to it because I understand the concepts underlying it. If an individual does not understand they can create filesystems in userspace (FUSE), if they don’t understand you can reverse engineer network requests, if they don’t understand cryptography, such an idea would not occur to them.</p> +<p>I’m not trying to claim I’m a genius by understanding these concepts or that I could easily build Cryptomator, but having an understanding of concepts is what allows for innovation, and without core knowledge, you are limited in what you can imagine.</p> +<p>Inversely, one might think it would be simple to create a competitor for YouTube, and ask an AI to help them with such a task. This is something that is exceptionally unreasonable. An individual without hundreds of millions in backing will not be able to compete with YouTube, but if one has no understanding of computing and the bounds of it, such an idea doesn’t seem entirely unreasonable. After all, someone else has done it so it must be possible. This seems to be a common issue, people who don’t know much about computing often think they have a great idea, but often it is just a derivative of something that exists because they don’t have a sufficient understanding of concepts to create novel things.</p> +<p>This is all to make the point that using AI is not a replacement for human thought. By using AI in this way, you will be bound to your creativity and its knowledge, neither of which is vast.</p> +<h2 id="solution">Solution</h2> +<p>Don’t use AI unless there is a very good reason to do so. At work I use AI quite frequently because I am being paid to be exceptionally productive, and while I know it is bad for my skills, it is what I am expected to do. Arguments can be made that humans can be as productive as humans with AI based on specific studies, but I find it unlikely, especially in modern tech companies. Modern tech companies are not building products to last decades, they are building products to last months. On such a time horizon, there is insufficient time to learn a codebase to become more productive than AIs.</p> +<p>Given this, I find the best approach to be doing personal projects. Personal projects aren’t corrupted by monetary incentives, they exist because of a passion for the craft, and an interest in something that doesn’t exist yet.</p> +<h2 id="citations">Citations</h2> +</body> +</html> diff --git a/posts/site_wip/all-roads-lead-to-gemtext.html b/posts/site_wip/all-roads-lead-to-gemtext.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>all-roads-lead-to-gemtext</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="all-roads-lead-to-gemtext">All Roads Lead to Gemtext</h1> +<pre><code>All roads lead to gemtext</code></pre> +</body> +</html> diff --git a/posts/site_wip/are-llms-useful.html b/posts/site_wip/are-llms-useful.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>are-llms-useful</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="are-llms-useful">Are LLMs Useful?</h1> +<h2 id="date-20250113">Date: 2025/01/13</h2> +<h2 id="motivating-usefulness">Motivating Usefulness</h2> +<h2 id="definition-of-usefulness">Definition of Usefulness</h2> +<h2 id="citations">Citations</h2> +</body> +</html> diff --git a/posts/site_wip/basic-software-profiling-part-1-cpu-usage.html b/posts/site_wip/basic-software-profiling-part-1-cpu-usage.html @@ -0,0 +1,315 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>basic-software-profiling-part-1-cpu-usage</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + /* CSS for syntax highlighting */ + html { -webkit-text-size-adjust: 100%; } + pre > code.sourceCode { white-space: pre; position: relative; } + pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } + pre > code.sourceCode > span:empty { height: 1.2em; } + .sourceCode { overflow: visible; } + code.sourceCode > span { color: inherit; text-decoration: inherit; } + div.sourceCode { margin: 1em 0; } + pre.sourceCode { margin: 0; } + @media screen { + div.sourceCode { overflow: auto; } + } + @media print { + pre > code.sourceCode { white-space: pre-wrap; } + pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } + } + pre.numberSource code + { counter-reset: source-line 0; } + pre.numberSource code > span + { position: relative; left: -4em; counter-increment: source-line; } + pre.numberSource code > span > a:first-child::before + { content: counter(source-line); + position: relative; left: -1em; text-align: right; vertical-align: baseline; + border: none; display: inline-block; + -webkit-touch-callout: none; -webkit-user-select: none; + -khtml-user-select: none; -moz-user-select: none; + -ms-user-select: none; user-select: none; + padding: 0 4px; width: 4em; + background-color: #ffffff; + color: #a0a0a0; + } + pre.numberSource { margin-left: 3em; border-left: 1px solid #a0a0a0; padding-left: 4px; } + div.sourceCode + { color: #1f1c1b; background-color: #ffffff; } + @media screen { + pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } + } + code span { color: #1f1c1b; } /* Normal */ + code span.al { color: #bf0303; background-color: #f7e6e6; font-weight: bold; } /* Alert */ + code span.an { color: #ca60ca; } /* Annotation */ + code span.at { color: #0057ae; } /* Attribute */ + code span.bn { color: #b08000; } /* BaseN */ + code span.bu { color: #644a9b; font-weight: bold; } /* BuiltIn */ + code span.cf { color: #1f1c1b; font-weight: bold; } /* ControlFlow */ + code span.ch { color: #924c9d; } /* Char */ + code span.cn { color: #aa5500; } /* Constant */ + code span.co { color: #898887; } /* Comment */ + code span.cv { color: #0095ff; } /* CommentVar */ + code span.do { color: #607880; } /* Documentation */ + code span.dt { color: #0057ae; } /* DataType */ + code span.dv { color: #b08000; } /* DecVal */ + code span.er { color: #bf0303; text-decoration: underline; } /* Error */ + code span.ex { color: #0095ff; font-weight: bold; } /* Extension */ + code span.fl { color: #b08000; } /* Float */ + code span.fu { color: #644a9b; } /* Function */ + code span.im { color: #ff5500; } /* Import */ + code span.in { color: #b08000; } /* Information */ + code span.kw { color: #1f1c1b; font-weight: bold; } /* Keyword */ + code span.op { color: #1f1c1b; } /* Operator */ + code span.ot { color: #006e28; } /* Other */ + code span.pp { color: #006e28; } /* Preprocessor */ + code span.re { color: #0057ae; background-color: #e0e9f8; } /* RegionMarker */ + code span.sc { color: #3daee9; } /* SpecialChar */ + code span.ss { color: #ff5500; } /* SpecialString */ + code span.st { color: #bf0303; } /* String */ + code span.va { color: #0057ae; } /* Variable */ + code span.vs { color: #bf0303; } /* VerbatimString */ + code span.wa { color: #bf0303; } /* Warning */ + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="basic-software-profiling-part-1-cpu-usage">Basic Software Profiling, Part 1: CPU Usage</h1> +<p>There aren’t many good resources that explain software profiling in an approachable and applicable way. I hope these posts can help readers understand basic software profiling techniques without getting too in the weeds, as I believe getting too into the nuances of performance tends to cause people to dismiss it as something too specialized to try reasoning about.</p> +<h2 id="tools">Tools</h2> +<p><a href="https://en.wikipedia.org/wiki/Perf_%28Linux%29">Perf</a> is your friend. Unfortunately, only one of the three most popular operating systems (Linux, OpenBSD, FreeBSD) supports perf, but there are sufficient analogs on FreeBSD, and if you’re on OpenBSD good luck.</p> +<p>You might also want a visualization tool. I’ll be showing <a href="https://github.com/brendangregg/FlameGraph">flamegraph</a>. Normally I just use perf because <a href="https://www.brendangregg.com/perf.html">it is very powerful</a>, but having pleasing visuals is useful for demonstrations (newer versions of <code>perf</code> can also generate flamegraphs directly, but they aren’t as aesthetic).</p> +<h2 id="reading-a-flamegraph">Reading a flamegraph</h2> +<p>Let’s start with something easy, how do you read a flamegraph? Take a look at the following flamegraph and, without my help, try to understand what’s being shown:</p> +<object data="https://blog.laack.co/images/ex1-fg.svg" type="image/svg+xml" width="100%"> +</object> +<p>The amount of time spent with the <code>main</code> function on the stack is represented by the width of its bar.</p> +<p>Notice how there are multiple bars that say <code>square</code>. This is because we execute <code>square</code> at different stack depths, and the width of each bar is dictated by the amount of time we spent with <code>square</code> on the call stack at a given stack depth.</p> +<p>Given how the widths are calculated, we can deduce the top-down width of a bar is how much time the program spent executing a specific function. In the case of <code>squareHelper</code> and <code>square</code>, we see we spent more time executing <code>squareHelper</code> than <code>square</code>, evidenced by the fact that from a top-down view, <code>squareHelper</code> is wider.</p> +<p>The astute among you might’ve noticed that <code>square</code> and <code>squareHelper</code> appear to sometimes be executed outside of the main loop. This is due to how stack depth is calculated, and that’s a bit more technical than I’ll be able to discuss here.</p> +<h2 id="perf">Perf</h2> +<p>I’ve been a little loose with my words thus far in describing flamegraphs. The command I’ve been using with perf to generate the data for flamegraphs isn’t tracking the amount of time spent with a function on the stack at a given depth, we are instead tracking the number of on-CPU samples taken with the function on the top of the call stack. This distinction is important because things like blocking I/O will not be reflected in our timings. Additionally, since perf is interrupt based, it may miss some data, but it gives a good enough approximation of CPU utilization.</p> +<pre><code>perf record -g ./ex1</code></pre> +<p>This is the command I ran to generate the data for the flamegraph. The <code>record</code> command is used to record events that will be written to the <code>perf.data</code> file. By default, <code>perf record</code> will sample at 1000Hz. The final option, <code>-g</code>, is used to specify we are interested in having the call stack included in our data.</p> +<p>If you want to generate a flamegraph right away, you can run the following command:</p> +<pre><code>perf script report flamegraph</code></pre> +<p>This isn’t how the flamegraph above was generated because I prefer Brendan’s FlameGraph program, but both are fairly similar, and in a pinch, <code>perf script report flamegraph</code> will work. A command I use more often to view performance is:</p> +<pre><code>perf report -g</code></pre> +<pre><code>+ 100.00% 0.00% ex1 ex1 [.] _start ++ 100.00% 0.00% ex1 libc.so.6 [.] __libc_start_main ++ 100.00% 0.00% ex1 libc.so.6 [.] call_init (inlined) ++ 100.00% 0.00% ex1 libc.so.6 [.] 0x00007f6302a27781 ++ 99.79% 39.46% ex1 ex1 [.] main ++ 34.97% 19.94% ex1 ex1 [.] squareHelper(unsigned int) ++ 29.99% 19.90% ex1 ex1 [.] square(unsigned int) ++ 21.61% 20.69% ex1 ex1 [.] factorial(unsigned int) +...</code></pre> +<p>or if I’m curious to see function calling information:</p> +<pre><code>perf report -g --stdio</code></pre> +<pre><code>... +|--88.87%--main +| | +| |--19.84%--squareHelper(unsigned int) +| | | +| | --4.99%--square(unsigned int) +| | +| |--19.55%--factorial(unsigned int) +| | +| --10.07%--square(unsigned int) +| +|--5.02%--squareHelper(unsigned int) +| +|--4.98%--square(unsigned int) +| +--1.13%--factorial(unsigned int) +...</code></pre> +<p>In many cases, I find the <code>--stdio</code> command a bit difficult to read because the report can get exceptionally wide for any non-trivial program (there are additional CLI options that can help with this), and such navigation in the terminal is difficult.</p> +<p>The final thing I wanted to mention is if you just want high level information about your program’s performance, this is a useful command:</p> +<pre><code>perf stat ./ex1</code></pre> +<pre><code> Performance counter stats for &#39;./ex1&#39;: + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 132 page-faults:u # 4.1 faults/sec page_faults_per_second + 32,436.48 msec task-clock:u # nan CPUs CPUs_utilized + 356,775 branch-misses:u # 0.0 % branch_miss_rate (88.89%) + 63,706,083,988 branches:u # 1964.0 M/sec branch_frequency (88.89%) + 134,126,037,336 cpu-cycles:u # 4.1 GHz cycles_frequency (88.89%) + 300,951,617,557 instructions:u # 2.2 instructions insn_per_cycle (88.89%) + TopdownL1 # 4.4 % tma_backend_bound + # 61.4 % tma_bad_speculation (88.89%) + # 0.0 % tma_frontend_bound (77.78%) + # 34.2 % tma_retiring (88.89%) + + 32.440411262 seconds time elapsed + + 32.234190000 seconds user + 0.002939000 seconds sys</code></pre> +<p>This is the command I run most frequently when validating optimizations where the optimization is targeting a portion of the codebase with an outsized footprint. If the program is more uniformly expensive, <code>perf stat</code> is likely less useful than a full report / flamegraph.</p> +<h2 id="what-to-optimize">What to optimize</h2> +<p>Start with the functions that are costing the most CPU time. Often a very small number of functions take up the majority of the computation, and these are the ones worth optimizing. As it relates to optimization in this context, I don’t expect most people to be hand coding assembly, and if you are, you already know all of this anyways. This is for the people just building normal software, consider what’s costly and ask yourself two questions:</p> +<ol type="1"> +<li>Would it be possible to call this function less often</li> +<li>Would it be possible to make each call of this function perform less work</li> +</ol> +<p>Work is key for most optimization; cache friendliness is important, but what I really want from software I use is for it to not leave tons of performance on the table by using bad algorithms, performing unexpected / unnecessary copies, or calling functions (like draw functions) when they don’t have to.</p> +<h2 id="amfora">Amfora</h2> +<p>Something useful to understand when profiling is the ideal case. Without a conception of how long (roughly) reading a file should take, transferring data, or drawing text, it’s hard to understand if performance is to be expected or abnormal. This is very contextual, so I can’t answer every question that’s relevant for this, but something I’ve found useful is comparing what I have with something that’s similar in ways I’d anticipate that result in similar performance to see where each implementation is spending a disproportionate amount of cycles.</p> +<p>To this end, when I was working on my Gemini protocol browser I wanted to compare it against a well known browser. Amfora states in the readme that it “aims to be the best looking Gemini client with the most features”, and while I absotlutely detest the idea that more features means slower in all cases, they do have some features that make it slower*. Specifically, they have syntax highlighting and per character coloring, neither of which my browser has, instead opting for a simpler line based coloring approach which I believe still results in nice looking gemtext because it’s all line based at the end of the day.</p> +<p>(* They could’ve done coloring as a second pass perhaps to improve perceived performance, but I’d imagine that’d be more complex, and it would increase the time to having the finalized text displayed)</p> +<p>I decided the first benchmark I was going to perform was a comparison between their performances when opening large files on my filesystem. This was quickly stopped when I realized amfora has a max file size limit of 2097152 bytes or ~2MB. That’s curious, but alright then. Let’s just make a file that’s bigger than 1MB.</p> +<p>This is a first pass at a direct comparison so I’m not going to make it the max size, and I’m not going to use a representative text, just a bunch of numbers.</p> +<div class="sourceCode" id="cb9"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="cf">with</span> <span class="bu">open</span>(<span class="st">&quot;lf.txt&quot;</span>, <span class="st">&quot;w&quot;</span>) <span class="im">as</span> f:</span> +<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">0</span>,<span class="dv">200000</span>):</span> +<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> f.write(<span class="bu">str</span>(i) <span class="op">+</span> <span class="st">&quot;</span><span class="ch">\n</span><span class="st">&quot;</span>)</span></code></pre></div> +<p>That should be good enough, the resulting file is ~1.3MB in size.</p> +<p>I then ran following command:</p> +<pre><code>perf stat amfora lf.txt + +Performance counter stats for &#39;amfora lf.txt&#39;: + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 2,742 page-faults:u # 9306.7 faults/sec page_faults_per_second + 294.63 msec task-clock:u # nan CPUs CPUs_utilized + 1,052,499 branch-misses:u # 0.2 % branch_miss_rate (90.02%) + 575,712,764 branches:u # 1954.1 M/sec branch_frequency (89.14%) + 955,922,330 cpu-cycles:u # 3.2 GHz cycles_frequency (87.42%) + 2,669,651,845 instructions:u # 2.8 instructions insn_per_cycle (88.36%) + TopdownL1 # 6.7 % tma_backend_bound + # 24.9 % tma_bad_speculation (90.11%) + # 16.4 % tma_frontend_bound (79.92%) + # 52.0 % tma_retiring (90.37%) + + 0.473990805 seconds time elapsed + + 0.272938000 seconds user + 0.021266000 seconds sys +</code></pre> +<p>This is quite unscientific because I simply Ctrl-C’d out once the first characters had rendered. Here’s the same for foreseen:</p> +<pre><code>perf stat foreseen lf.txt + + Performance counter stats for &#39;foreseen lf.txt&#39;: + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 8,936 page-faults:u # 104842.2 faults/sec page_faults_per_second + 85.23 msec task-clock:u # nan CPUs CPUs_utilized + 209,148 branch-misses:u # 0.1 % branch_miss_rate (88.30%) + 176,970,330 branches:u # 2076.3 M/sec branch_frequency (88.29%) + 248,919,966 cpu-cycles:u # 2.9 GHz cycles_frequency (88.29%) + 736,194,375 instructions:u # 3.0 instructions insn_per_cycle (88.99%) + TopdownL1 # 3.9 % tma_backend_bound + # 29.7 % tma_bad_speculation (89.50%) + # 21.2 % tma_frontend_bound (77.84%) + # 45.2 % tma_retiring (88.33%) + + 0.354029324 seconds time elapsed + + 0.066861000 seconds user + 0.021186000 seconds sys</code></pre> +<p>Of these metrics, the most comparable one is CPU cycles because they aren’t spinning during the time it took me to react to the text having been rendered, but even so, this isn’t a very good benchmark, and it’s not something I’d post about.</p> +<p>Since Amfora can highlight code, let’s see how the performance comparse if we just add our python code block to the top of that file, and rename it to lf.gmi:</p> +<pre><code>perf stat amfora lf.gmi + + Performance counter stats for &#39;amfora lf.gmi&#39;: + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 900,174 page-faults:u # 12090.4 faults/sec page_faults_per_second + 74,453.35 msec task-clock:u # nan CPUs CPUs_utilized + 229,042,926 branch-misses:u # 0.4 % branch_miss_rate (88.94%) + 62,713,218,442 branches:u # 842.3 M/sec branch_frequency (88.85%) + 153,193,058,619 cpu-cycles:u # 2.1 GHz cycles_frequency (88.97%) + 306,159,421,078 instructions:u # 2.0 instructions insn_per_cycle (88.90%) + TopdownL1 # 0.6 % tma_backend_bound + # 97.8 % tma_bad_speculation (88.83%) + # -0.1 % tma_frontend_bound (77.86%) + # 1.7 % tma_retiring (88.91%) + + 28.983517177 seconds time elapsed + + 63.894262000 seconds user + 8.207151000 seconds sys</code></pre> +<p>Woah, that’s a lot slower. With foreseen there shouldn’t be any difference because each line is treated ~ the same, so something’s up here. Let’s look at a flamegraph for this.</p> +<object data="https://blog.laack.co/images/amfora-before.svg" type="image/svg+xml" width="100%"> +</object> +<p>So 68.34% samples occurred while executing the GC, that’s a bit surprising, even given how awful garbage collectors are. We also see that 25.47% of the time, most of the remaining time, is spent in the RenderGemini function. Of this, most of it is spent on concatstring3, a function under the hood that’s used to concatenate strings.</p> +<p>Here’s where that’d be used in the function:</p> +<pre><code>rendered += fmt.Sprintf(&quot;[%s]&quot;, config.GetColorString(&quot;preformatted_text&quot;)) + + buf + fmt.Sprintf(&quot;[%s:%s:-]\r\n&quot;, config.GetColorString(&quot;regular_text&quot;), config.GetColorString(&quot;bg&quot;)) + +... + +rendered += buf + &quot;\r\n&quot; + +... + +rendered += ren + +... + +buf += strings.TrimSuffix(lines[i], &quot;\r&quot;) + &quot;\r\n&quot;</code></pre> +<p>Well, there’s our problem; each of these seemingly innocuous appends is actually very costly. Unlike sensible OO / procedural programming languages, Go strings are immutable so each of these operations will create an entirely new string each time, and since we accumulate into <code>buf</code> until reaching a preformatted text switch line (“```” lines), the file we were trying to open has to re-create the full string 200,000 times, since we only have the tail 200,000 lines in the file don’t have a format switcher.</p> +<p>This is relatively trivial to solve by using a strings.Builder which doesn’t have this issue, and that’s <a href="https://github.com/makew0rld/amfora/pull/370/changes">what I did</a>*. After this change, we can perform our profiling again to find:</p> +<p>(NOTE: The profiling I did to find this differed slightly from what’s shown here, hence the difference in numbers between what we see now, and what’s seen in the PR, but they’re similar enough)</p> +<pre><code>perf stat amfora lf.gmi + + Performance counter stats for &#39;amfora lf.gmi&#39;: + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 6,039 page-faults:u # 4871.9 faults/sec page_faults_per_second + 1,239.55 msec task-clock:u # nan CPUs CPUs_utilized + 3,631,996 branch-misses:u # 0.1 % branch_miss_rate (89.02%) + 3,017,891,055 branches:u # 2434.7 M/sec branch_frequency (88.96%) + 4,654,531,574 cpu-cycles:u # 3.8 GHz cycles_frequency (88.93%) + 14,168,541,807 instructions:u # 3.1 instructions insn_per_cycle (88.81%) + TopdownL1 # 2.2 % tma_backend_bound + # 36.9 % tma_bad_speculation (88.80%) + # 18.5 % tma_frontend_bound (77.83%) + # 42.5 % tma_retiring (88.90%) + + 1.185772969 seconds time elapsed + + 1.193871000 seconds user + 0.039062000 seconds sys</code></pre> +<p>Much better, that’s now using 32x less cycles, and is far faster than before.</p> +<object data="https://blog.laack.co/images/amfora-after.svg" type="image/svg+xml" width="100%"> +</object> +<p>Looking again at the flamegraph, we see the RenderGemini function is now mostly performing word wrapping, and the GC is only utilizing the CPU during 16.48% of our samples, much better.</p> +<p>We can go deeper into this if we’d like, but there are now 3 ~equally costly groupings, and as performance becomes more diffuse, optimizations will generally have a smaller amount of impact on perf, so we can leave this where it is.</p> +<h2 id="refutations">Refutations</h2> +<p>I think everything above paints a picture that you don’t have to put in that much effort to, in many cases, make things a lot better, and you don’t have to be that well versed in optimization either.</p> +<p>I often hear arguments about how we should just let other people make software and we’ll just use it and be happy because they’re smarter / better than us at it, this is often the case with libraries, and I so vehemently disagree with this idea. Amfora is a piece of software with 1.4K Github stars, that’s existed for &gt; 6 years with 54 contributors; it’s not tiny, and yet a glaring issue took this long to find and solve.</p> +<p>While I do think there is blame in this situation, I don’t think there should be any shame in writing bad software, but it’s all of our jobs to make our software a little less bad over time, hopefully you can do the same, and help others with that too.</p> +<h2 id="whats-next">What’s Next</h2> +<p>Consider learning memory profiling next. I didn’t directly discuss the topic because 1) it’s more complex and 2) memory related performance issues often manifest, like we saw in the go example, as CPU performance issues too. I also didn’t discuss anything related to instrumented profiling; everything I’ve shown with perf can be done without changing any code. When you can change the code, you have the ability to get more granular than just getting metrics on the basis of functions. Despite the upsides of instrumented profiling, I rarely do it because it often takes more time. The main context where I do it is to get shareable information with others, in a working context, and for intra-function profiling.</p> +<p>Memory stuff is also more complex across languages, where they do weird stuff like go not using malloc.</p> +</body> +</html> diff --git a/posts/site_wip/complexity-facilitates-opression.html b/posts/site_wip/complexity-facilitates-opression.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>complexity-facilitates-opression</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="complexity-facilitates-opression">Complexity Facilitates Opression</h1> +<p>Web browsers are complicated pieces of software. The complexity in making a web browser is why there weren’t any fundamentally new web browsers for many years until the LadyBird browser began development.</p> +<p>This complexity built a moat around Mozilla and Google, allowing them to maintain a duopoly on browsers. While derivative browsers exist that are built on the underlying open source projects, these browsers are no more than a reskin of the existing browsers.</p> +</body> +</html> diff --git a/posts/site_wip/default-cracked.html b/posts/site_wip/default-cracked.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>default-cracked</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="default-cracked">Default: Cracked</h1> +<p>Language models aren’t default cracked. Be default cracked; stand in their face and spit in it.</p> +</body> +</html> diff --git a/posts/site_wip/dissatisfaction.html b/posts/site_wip/dissatisfaction.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>dissatisfaction</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="dissatisfaction">Dissatisfaction</h1> +<p>It is quite dissatisfying to not feel in control. I feel this way when people try to advertise to me. “Buy our thing, it solves a problem for you, without us you’d never be able to solve it!”, debilitating.</p> +</body> +</html> diff --git a/posts/site_wip/do-tools-actually-matter.html b/posts/site_wip/do-tools-actually-matter.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>do-tools-actually-matter</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="do-tools-actually-matter">Do Tools Actually Matter</h1> +<p>I think about fuzzing / pbt and cool outcomes. that’s great. Is this just on the edge? Are the kinds of ppl who use these things the kinds of people who would find these issues even if they had shit tools? I was trying to find a snapshot based testing tool in C++ to validate serialized data models and realized I don’t really give a fuck and can just use asserts, one write string to file function, one read file to string.</p> +<h2 id="does-it-matter">Does it matter</h2> +<p>I think vet kinda matters because there are optimizations we performed to find issues. So in a sense, that’s better than just using a LM and saying find shit. In a similar vein, if we compare something using a better complexity heuristic, like LEOPARD-V, it’ll be a better (fuzzer) than if it was just using some sort of naive code coverage metric, assuming consistent runtimes and non-exhaustive search.</p> +</body> +</html> diff --git a/posts/site_wip/encrypted-messaging.html b/posts/site_wip/encrypted-messaging.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>encrypted-messaging</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="encrypted-messaging">Encrypted Messaging</h1> +<h2 id="date-20260130">Date: 2026/01/30</h2> +<h2 id="acceptability">Acceptability</h2> +<p>I am only willing to use E2E encrypted messaging platforms, barring exceptions for work and school.</p> +</body> +</html> diff --git a/posts/site_wip/greyscale-shader.html b/posts/site_wip/greyscale-shader.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>greyscale-shader</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<p>greyscale shader is cool. made eyes hurt once? will happen again?</p> +</body> +</html> diff --git a/posts/site_wip/how-i-learn.html b/posts/site_wip/how-i-learn.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>how-i-learn</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="how-to-learn">How to Learn</h1> +<p>A few things are agreed upon in terms of their efficacy in aiding learning:</p> +<ol type="1"> +<li>Spaced repetition +<ul> +<li>Do things over time that exercise memories</li> +</ul></li> +<li>Retrieval practice +<ul> +<li>Pull from memory to answer questions, write about a topic, remember what you read / saw</li> +</ul></li> +<li>Interleaving +<ul> +<li>Helps with dis-ambiguating similar topics</li> +</ul></li> +<li>Self-explanation / interrogation +<ul> +<li>Ask questions to yourself, explain topics to yourself (consider another person and how you might explain it to them)</li> +</ul></li> +</ol> +</body> +</html> diff --git a/posts/site_wip/how-to-choose-software.html b/posts/site_wip/how-to-choose-software.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>how-to-choose-software</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="how-to-choose-software">How to Choose Software</h1> +<p>TODO: Edit TODO: Make this more focused / actionable TODO: What even is my point? what even do I think? TODO: I guess one thing I think is that you probably won’t be happier with new things. TODO: You probably are also wasting time, and you might be led back to where you started. TODO: I’d also like some sort of flow chart for this. We shall see TODO: Maybe say to build your own software?</p> +<h2 id="constraints">Constraints</h2> +<p>These are my opinions about software selection. I have been thinking about this extensively as of late because I was curious about what software existed to take notes, but this invariably led me back to where I started many years ago, vim. I have recently realized that left unbounded I will explore the same loops indefinitely. I have done this before. I last time I started with vim, used vim-wiki for ~1 years, tried nextcloud notes for a few hours, mediawiki for a few hours, logseq for a few hours, zettlr for a few hours, and circled back to vim, but this time with oil for filesystem manipulation.</p> +<p>This was basically the same loop I went through years ago as well. I had been using vim for a while, tried some other things, and went in almost an identical loop that time as well. This is because I have specific requirements for note taking software that constrains software I would consider trying. Such constraints are listed below:</p> +<ol type="1"> +<li>Free software</li> +<li>Markdown only, no db</li> +<li>No data collection of any kind by default +<ul> +<li>This includes auto-updating which you can’t disable in qownnotes.</li> +</ul></li> +</ol> +<p>Beyond this, I have expectations of performance, but this is on a case by case basis, but was what originally led me away from nextcloud. I mention these constraints because I think they are a useful starting point for software selection. First, start by stating what you are not looking for. I find this to be easier than saying what I am looking for because there is potential for programs to provide functionality that is life-changing, but I would’ve never considered before.</p> +<h2 id="what-you-want">What you want</h2> +<p>I said saying what you want is hard, and it is, but there are some primitives you probably are interested in. A few primitives I wanted are listed below:</p> +<ol type="1"> +<li>Ability to take MD notes with in-line LaTeX rendering</li> +<li>Standard MD format, no special formatting / syntax</li> +<li>Simple to configure without requiring adopting some ritualistic note taking practices</li> +</ol> +<p>This was really it for me.</p> +<h2 id="where-i-went-wrong">Where I went wrong</h2> +<p>I went wrong by believing there could be something I hadn’t ever thought of but would significantly alter my life. I have had the same issue with keyboards, programming languages, and software. Basically, there is this sense that there might be something better out there so I should always keep looking. In the end though, I use gateron clears, I write code mostly in C++, and I use vim, dwm, and tmux for basically all things computing related.</p> +<h2 id="how-to-fight-this">How to fight this</h2> +<p>I haven’t figured this out yet. I suspect I can fight this by asking myself the question, “What am I looking for to be better?”. If I can’t answer this question, I shouldn’t continue searching. I still will probably continue looking, but this question seems to at least decrease my fervor. Another thing to consider is this; what software do you like?</p> +<p>For me, I like suckless software, generally. Knowing this, a simple heuristic for search is that of simplicity. Is there something that has less features than what I am using right now that doesn’t remove the features I use? Or, is there something out there that has a feature I would use. This is again dangerous.</p> +<h2 id="never-happy">Never happy</h2> +<p>You will never be happy with your software. You will always believe there might be something better out there. That is okay. Should you continue looking for it? That depends how much it matters to you. If this is somethign you enjoy, maybe. If this is something you get paid for, probably. If this is something you do and get some enjoyment out of, but is overall a distraction, probably not. The final category is the one I find myself in. There are so many things for me to study, research, and work on so spending time on these sorts of things, while slightly enjoyable, is often not worthwhile.</p> +<p>This leads me to conclude the following; stick with what you have. Select software that is simple and does one thing well. If you want more things, find single programs that add that to what you already have. If you want better note taking in some ways, use nb or vim-wiki. If you want a better editor frontend, find one, but don’t try to find a program that does everything for you. This will invaraibly be too tall of an ask and will miss some things that others do better, but do some thingss better than others. There is no way to win except building everything from the bottom-up slowly and over time.</p> +</body> +</html> diff --git a/posts/site_wip/ideal-note-taking.html b/posts/site_wip/ideal-note-taking.html @@ -0,0 +1,76 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>ideal-note-taking</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="ideal-note-taking">Ideal Note Taking</h1> +<p>The ideal note taking setup supports the users’ preferred note taking modalities. For me these are textual notes, frequently taken in reference to an information source alongside planning for subsequent notes, information sources, and time allotments.</p> +<p>Additionally, it must not be built into a text editor. My text editor (vim) is for editing notes, not organizing them.</p> +<p>I use git for managing persistent, non-binary data, and so my note taking program should work well with git, but it shouldn’t have a git integration because that seems beyond the scope of what a note-taking program should do. Similarly, it should be simple to encrypt my notes, but CryFS[1] does this for me, and it is very clearly outside the scope of what a note-taking program should facilitate.</p> +<h2 id="specifics">Specifics</h2> +<p>The above is a high-level, these are the specifics of what I want:</p> +<ul> +<li>Multi-directory support +<ul> +<li>I have notes in directories with different threat models, and they should remain logically separated</li> +</ul></li> +<li>Terminal-based</li> +<li>No built-in backups / synchronization +<ul> +<li>I don’t want sync functionality because that’s what git is for, or network shares, or unison, and these add both complexity and support silly use cases like taking notes from mobile devices</li> +</ul></li> +<li>To-Do tracking +<ul> +<li>When taking notes I frequently find related resources or think of related note-taking topic, and I’d like a list of these things.</li> +</ul></li> +<li>Stable and performant +<ul> +<li>Apart from mixing concerns and being proprietary, programs like Notion and Obsidian are both unacceptably unstable and slow.</li> +</ul></li> +<li>Scriptability +<ul> +<li>It should be easy to write scripts for programmatic invocations of the program.</li> +</ul></li> +<li>Archiving +<ul> +<li>When I take notes I often want to archive sources for future reference, this should be supported by the program.</li> +</ul></li> +<li>Interoperable +<ul> +<li>The resulting directory structures should be reasonable for use with SSGs and other tools that have sensible expectations.</li> +</ul></li> +</ul> +<h2 id="implementation">Implementation</h2> +<p>I want this to be performant so it must be written in a language that can compile to a sane binary. I don’t want to become suicidal from using an object oriented language so I am going to choose Go.</p> +<h1 id="citations">Citations</h1> +<p>[1] - <a href="https://www.cryfs.org/">https://www.cryfs.org/</a></p> +</body> +</html> diff --git a/posts/site_wip/interesting-tests-ive-written.html b/posts/site_wip/interesting-tests-ive-written.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>interesting-tests-ive-written</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="interesting-tests-ive-written">Interesting Tests I’ve Written</h1> +<h2 id="prims-algorithm">Prim’s Algorithm</h2> +<h3 id="pbt-inadmissable">PBT Inadmissable</h3> +<p>Prim’s algorithm. Created a comparison for random spanning tree inductions, starting at random vertex of connected graph, select random vertex that’s already been visited, follow edges until all vertices have been visited. Assert rnd spanning tree weight &lt;= mst weight.</p> +<p>https://git.laack.co/abg/commit/4a265d34937ad339697218e4fd919b17b678ab6d.html</p> +<p>The generalization of this is an algorithmic PBT where we assert an inadmissible heuristic is never better than an admissible heuristic.</p> +<h3 id="snapshots">Snapshots</h3> +<p>Defined toString() serialization functions for each of my objects, verifying that prior snapshot matches current snapshot. This was interesting because I realized converting from an unordered_map&lt;int,Edge&gt; =&gt; vector<Edge>, despite them representing the same data because the ints were from 0 -&gt; n, this changed the ordering of my graph. Good reminder that unordered_map is not ordered, and led me down the rabit hole of figuring out how stable the ordering of unordered_maps actually are. This was interesting too because it reminded me I was relying on the structure of something that wasn’t well defined, UB if you will.</p> +<h2 id="vet">Vet</h2> +<h3 id="e2e-time-test">E2E Time Test</h3> +<p>Time based e2e test for specific command. vet –help, and some other stuff was stupidly fucking slow because of imports of model providers so I wrote a test to assert this wasn’t slow. This actually caught an issue with a PR someone submitted to me.</p> +<p>This could’ve been a snapshot-type test too, but that’d have perhaps been too stringent / subject to variance.</p> +<p>There is potential for issues w/ this type of test, but it seems to generally be within reason when the time deltas are very large, and your infra is pretty okay, even github action runners!</p> +<h2 id="watermelon-problem">Watermelon Problem</h2> +<h3 id="oracle">Oracle</h3> +<p>Generation of inputs and outputs using a naive algorithm and then verifying io for the proper algorithm.</p> +</body> +</html> diff --git a/posts/site_wip/just-because-youre-right-doesnt-mean-it-matters.html b/posts/site_wip/just-because-youre-right-doesnt-mean-it-matters.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>just-because-youre-right-doesnt-mean-it-matters</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="just-because-youre-right-doesnt-mean-it-matters">Just because you’re right doesn’t mean it matters</h1> +<ul> +<li>Free software +<ul> +<li>yes, proprietary software will generally become crap, no that doesn’t mean free software is necessarily the correct course of action</li> +</ul></li> +<li>Yes, package managers will always be supply chain attack vectors, no it doesn’t mean we definitively shouldn’t use them +<ul> +<li>This is just a consequence of them, not something that obviates their entire value prop</li> +</ul></li> +</ul> +<p>basically, it is super easy to predict something bad will happen in the future. This doesn’t mean the bad thing you predicted matters, and frequently predictions about bad things happening are outweighed by the positive short term benefits. The specifics of this are variable, and I do think free software is better than proprietary software, but it’s not that useful to say stallman was right because of course he would be! Of course some prop software will become bad, this is super obvious to me. What’s less obvious is his overall correctness, which I agree with, but is a bit more nuanced than a simple stallman was right because muh pdf viewer is crap now.</p> +</body> +</html> diff --git a/posts/site_wip/lets-make-all-software-faster.html b/posts/site_wip/lets-make-all-software-faster.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>lets-make-all-software-faster</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<p>was making gemini browser {link}.</p> +<p>benchmarking large file load times against amfora and was very surprised by perf.</p> +<p>made flamegraph to understand what the problem was with amfora. saw tons of time spent on gc, thought that was it. looked a bit deeper — there’s this 3 string op that was taking a shitload of time. tracked it down, found O(n^2) for unformatted text. fixed it.</p> +<p>amfora is still relatively slow, but let’s do our part, if we can, to make everything a little bit less slow</p> +</body> +</html> diff --git a/posts/site_wip/my-definition-of-good-software.html b/posts/site_wip/my-definition-of-good-software.html @@ -0,0 +1,60 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>my-definition-of-good-software</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="my-definition-of-good-software">My Definition of Good Software</h1> +<h2 id="obvious-attributes-of-good-software">Obvious Attributes of Good Software</h2> +<p>These are attributes of good software that I deem so obvious they needn’t be discussed any further.</p> +<ul> +<li>Distributed under a Free license</li> +<li>Free from malware, as described by the FSF [1]</li> +</ul> +<h2 id="less-obvious-attributes">Less Obvious Attributes</h2> +<ol type="1"> +<li>Written in C, assembly, a functional programming language, or POSIX shell</li> +</ol> +<p>Software written in C can be good because C is a performant language that has compilers for most operating systems and architectures. Moreover, C compilers are simple to make which allows for ease of distribution of C code across new operating systems and architectures.</p> +<p>Software written in functional programming languages can be good because functional languages provide assurances about the software. Functional languages enforce no side effects and immutability. While this can slow down software, it gives useful guarantees about its correctness.</p> +<p>Software written in POSIX shell can be good because, similar to C, it is highly portable, and there are cases where using scripting languages can make sense.</p> +<ol start="2" type="1"> +<li>Minimal Dependencies</li> +</ol> +<p>Software with more dependencies is more brittle. It often relies on the continued development of other projects, often when not entirely necessary.</p> +<p>There is no expectation for software to be entirely self contained, but lots of consideration should be given prior to adding dependencies to software.</p> +<ol start="3" type="1"> +<li>Easy Patching</li> +</ol> +<p>DSLs suck. Patching the software should be easy and done in the language the program was written in. This allows for users to transfer their understanding of languages to the tools they use without having to learn idiosyncratic syntax for config files.</p> +<h2 id="citations">Citations</h2> +<p>[1] - https://www.gnu.org/proprietary/proprietary.html</p> +</body> +</html> diff --git a/posts/site_wip/my-favorite-piece-of-software.html b/posts/site_wip/my-favorite-piece-of-software.html @@ -0,0 +1,141 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>my-favorite-piece-of-software</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="the-my-favorite-piece-of-software">The My Favorite Piece of Software</h1> +<h2 id="some-possible-options">Some Possible Options</h2> +<p>To start, I’d like to list the software I use frequently that I don’t detest. This list is short so it will be exhaustive, and from there I will filter down the list.</p> +<ul> +<li>Browsers +<ul> +<li>Qutebrowser</li> +<li>Librewolf</li> +<li>Lynx</li> +</ul></li> +<li>Mail clients +<ul> +<li>Thunderbird</li> +</ul></li> +<li>Text Editors +<ul> +<li>Neovim</li> +</ul></li> +<li>Operating Systems +<ul> +<li>GNU/Linux</li> +<li>OpenBSD</li> +<li>FreeBSD</li> +</ul></li> +<li>Tools +<ul> +<li>Git</li> +<li>Fzf</li> +<li>Dmenu</li> +<li>TCC</li> +<li>GCC</li> +<li>Rsync</li> +<li>Unison</li> +</ul></li> +<li>Document Conversion/Viewing +<ul> +<li>Pandoc</li> +<li>PDFLatex</li> +<li>Zathura</li> +</ul></li> +<li>Window Managers +<ul> +<li>DWM</li> +</ul></li> +<li>Other +<ul> +<li>Newsboat</li> +<li>DVTM</li> +<li>Tmux</li> +<li>St</li> +<li>Entr</li> +</ul></li> +</ul> +<h2 id="filtering">Filtering</h2> +<p>I like Lynx quite a bit, but most of the other browsers feel like the lesser of evils. In particular, I don’t think JavaScript on the web is a good idea (JavaScript is basically just RCE in a <em>controlled</em> environment), but I also realize it is a requirement for the modern web, and sometimes I am compelled to use some modern websites.</p> +<p>I quite like Thunderbird’s simplicity to use. I have found mail clients like mutt and neomutt a bit difficult to get working with mainstream email hosting providers, and Thunderbird simplifies this greatly. It is also extremely easy to use OpenPGP with which is great. The only thing I am not a huge fan of with Thunderbird is it is a bit heavy, weighing in at 255.62 MiB (currently) when downloaded via pacman.</p> +<p>Neovim is a decent text editor. I like its ease of extension, but there are some built in features, like a terminal, that I’d prefer if they didn’t exist. It would be reasonable if there was a plugin to add that, but I dislike that it is shipped with the product.</p> +<p>GNU/Linux, OpenBSD, and FreeBSD are all good operating systems with their own benefits and drawbacks. I struggle to say any are my favorite piece of software though because they are all very complicated. This makes sense because each of them supports a wide variety of hardware, but it saddens me a bit that different hardware requires special considerations as this really shouldn’t be the case.</p> +<p>Git has many features I don’t want and rebasing allows for easy rewriting of history. I’m on the fence about whether rewriting history should even exist, but making it easy is something I <em>really</em> don’t want.</p> +<p>Fzf is phenomenal at its job. It functions similarly to dmenu except from the terminal. Unfortunately, it is written in Go.</p> +<p>TCC and GCC are the two C compilers I use. GCC is quite slow so while it is very good at optimization, it isn’t my favorite. TCC is honestly awesome. It is so fast and just works. It compile C code and that’s that.</p> +<p>Rsync and Unison are my preferred ways to synchronize files between systems. Unison can be a bit tedius to ensure directories stay synchronized because of how hard it is to merge file changes (heck, that’s why VCSs exist). This isn’t an issue with Unison, moreso the issue it’s trying to resolve.</p> +<p>Pandoc is pretty awesome. It converts across (pan) document types in a performant manner and gives descriptive errors when things go wrong.</p> +<p>PDFLatex is the latex to PDF converter I use. Some people seem to have compatibility issues with it, but my LaTeX needs are quite limited so it does the job. That said, I find LaTeX’s slowness a bit annoying. Understandable, but annoying. As such, no LaTeX tooling can be my favorite piece of software.</p> +<p>Zathura is a document viewer that relies on other renderers, like MuPDF, to display and navigate documents. I quite like Zathura, but I’m not a huge fan of file formats that aren’t entirely text based, like PDF, which limits my appreciation for the software.</p> +<p>DWM is a pretty good tiling window manager. It is simple, performant, and portable.</p> +<p>Newsboat is the best RSS feed reader I have used. It is however written in C++ which is not my preference.</p> +<p>DVTM is pretty decent, but I’ve experience some weird issues when reattaching to DVTM sessions with abduco. Also, it sometimes enters into weird states that don’t allow text inputs. For these reasons, it isn’t the best piece of software.</p> +<p>Tmux is a pretty solid piece of software, but it is a bit too featureful.</p> +<p>St is the best terminal emulator I have ever used.</p> +<p>Entr is simple, elegant, and extremely useful for document compilation on file change, and code recompilation on file change.</p> +<h2 id="filtered-list">Filtered List</h2> +<p>Given the above, here is my filtered list of software that might be my favorite:</p> +<ul> +<li>Lynx</li> +<li>Dmenu</li> +<li>TCC</li> +<li>Rsync</li> +<li>Pandoc</li> +<li>DWM</li> +<li>Entr</li> +<li>St</li> +</ul> +<p>Of the items on this list, I’m going to eliminate Entr, Pandoc, and Rsync from the running. Entr does its job and does it well, but its job is very small wrt how I do computing. I mostly use Pandoc for converting to PDF or HTML. While I like the HTML conversion quite a bit, if it were up to me, PDFs wouldn’t exist, and thus quite a bit of Pandoc’s functionality feels like a symptom of poor choices that led to this point. Rsync is also getting removed from the list because it is too complicated. There are CVEs related to Rsync that make systems vulnerable to exploits in non-trivial ways. There might be vulnerabilities in St, but they are often mitigated by the fact that St is not a program that uses networking.</p> +<h2 id="continued-filtering">Continued Filtering</h2> +<p>We are left with these final five options:</p> +<ol type="1"> +<li>Lynx</li> +<li>Dmenu</li> +<li>TCC</li> +<li>DWM</li> +<li>St</li> +</ol> +<p>I can eliminate Dmenu because while it is good, I prefer non-graphical software to graphical software in most cases. From here, eliminating more pieces of software is exceedingly difficult. Each of the remaining pieces of software are extremely useful, and designed impeccably.</p> +<ol type="1"> +<li>Lynx</li> +<li>TCC</li> +<li>DWM</li> +<li>St</li> +</ol> +<p>I’m going to eliminate DWM and St next. While I appreciate both, I want my computing experience to not require graphical interfaces, and since these are both graphical programs, I am going to eliminate them.</p> +<ol type="1"> +<li>Lynx</li> +<li>TCC</li> +</ol> +<p>Lynx is enjoyable to use.</p> +</body> +</html> diff --git a/posts/site_wip/my-ideal-vcs.html b/posts/site_wip/my-ideal-vcs.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>my-ideal-vcs</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="my-ideal-vcs">My Ideal VCS</h1> +<p>These are some things I want from a VCS and how I would implement that.</p> +<ul> +<li>Patch based</li> +<li>Simple to use</li> +<li>Simple to understand</li> +<li>Minimal code</li> +<li>Written in C</li> +</ul> +<p>Most of the complexty from VCSs iss how they manage the resolution of conflicting changes. As such, I’d rather not implement that. This should be left as a job for either a) the editor/IDE or b) the humans responsible for the changes.</p> +<p>I get concerned by automatic merge conflict resolutions because changes within given file that act upon similar lines of code can often cause unexpected side effects when they are reliant upon the same variables in code. Given this, a human must be in the loop when resolving these conflicts, unless an exceptionally sophisticated VCS uses ASTs to determine if there is interdependence between the code. As such, I’d like my VCS to see when there are changes from differing patches on the same files and inform the use about this. These conflicts should then be resolved by a subsequent patch that combines the prior two patches into one.</p> +</body> +</html> diff --git a/posts/site_wip/rent-seeking-software.html b/posts/site_wip/rent-seeking-software.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>rent-seeking-software</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="rent-seeking-software">Rent-Seeking Software</h1> +<h2 id="learned-helplessness">Learned Helplessness</h2> +<p>Rent-seeking behavior is when individuals manipulate policy and market conditions to amass wealth without providing value. In some contexts, like actual rent, such behaviors are quite logical; property is a scarce resource, there are laws around development, and so there is an incentive to manipulate these laws to amass wealth.</p> +<p>The confusing part of this is why rent-seeking behavior exists in software. Instructure provides no value in their hosting of Canvas beyond what two sysadmins could manage with a VPS, the software is licensed under the AGPL so they are not peddling proprietary software, they have simply tricked people into believing they are helpless to do anything such that they have to pay for every service they want.</p> +<p>Frequently people claim it is cheaper to outsource their software services, which I am highly suspicious of, and it decreases their exposure in the case of a cybersecurity incident. This is such an inconsiderate stance. If a crime is commited against your employees, your customers, or the public and your primary concern is how this will impact you financially you are failing morally.</p> +<p>People selfhost services all the time. This isn’t something that requires a high degree of sophistication, just the ability to read, and a couple of weekends. I find selfhosting to be more difficult than hosting commercial software because hosting commercial software generally comes with commercial resources whereas selfhosting frequently means running docker on a rasberry pi sitting on the floor, a much less resilient configuration.</p> +<hr /> +<p>This is sort of all over the place, but this is reactionary to the canvas / instructure breach which has impacted a fairly sizeable number of students who really shouldn’t’ve been impacted by this because this was likely an instructure problem, not a canvas problem (shinyhunters seem to mostly do social engineering type stuff).</p> +</body> +</html> diff --git a/posts/site_wip/should-i-be-using-llms-for-learning.html b/posts/site_wip/should-i-be-using-llms-for-learning.html @@ -0,0 +1,54 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>should-i-be-using-llms-for-learning</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="should-i-be-using-llms-for-learning">Should I Be Using LLMs For Learning?</h1> +<p>I originally considered writing about whether I thought LLMs would ‘revolutionize’ education, but I was recently reminded how difficult it is to predict the future. An evaluation of the merits of LLMs for education does not lead to a conclusion about the ‘revolutionization’ of education, and given the investment into AI, along with uncertainty about payoffs, it’s even more difficult to predict where such things will invariably lead to.</p> +<p>Instead, let’s tackles a specific issue, “should you be using LLMs for learning”? I’d like to start this with my personal view on the matter: I would not recommend using LLMs for learning. Without considering the merits of LLMs for learning, there are ethical reasons I would warn against using them for education. Specifically:</p> +<ul> +<li>Support of proprietary software ecosystems / networked software +<ul> +<li>Most language models worth learning from would likely be prohibitively expensive to run so one’d use someone else’s compute which is functionally proprietary</li> +</ul></li> +<li>Intellectual property theft +<ul> +<li>I am not opposed to such things, but many are, so perhaps it’s worth considering</li> +</ul></li> +<li>Fear-mongering +<ul> +<li>The fear mongering being done by these AI companies about job loss and the ideological push that you’ll be ‘left behind’ are doing societal harm</li> +</ul></li> +</ul> +<h1 id="should-i-pay-a-tutor">Should I Pay a Tutor</h1> +<p>Also probably not. Seems like they aren’t better than step-wise learning https://www.tandfonline.com/doi/abs/10.1080/00461520.2011.611369.</p> +</body> +</html> diff --git a/posts/site_wip/the-best-privacy-browser.html b/posts/site_wip/the-best-privacy-browser.html @@ -0,0 +1,99 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>the-best-privacy-browser</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="the-best-privacy-browser">The Best Privacy Browser</h1> +<p>The best privacy browser is Tor, but that doesn’t help anyone. The question then becomes this: “What is the most privacy respecting browser that is usable?”</p> +<p>Usable is doing a lot of heavy lifting. In general, there are two levels of usability requirements. My requirement is most websites work. For me, this means Lynx isn’t usable for day to day use, but a browser like librewolf is. This divide is two fold:</p> +<ol type="1"> +<li>It must support JS</li> +<li>It mustn’t route traffic through a network that is frequently blocked by sites +<ul> +<li>this excludes tor for general use</li> +</ul></li> +</ol> +<hr /> +<p>The three browsers worth using, ordered by privacy descending:</p> +<ol type="1"> +<li>Tor Browser</li> +<li>Mullvad Browser</li> +<li>Brave Browser</li> +</ol> +<p>I no longer recommend firefox or any of the normal derivatives (like librewolf / arkenfox).</p> +<hr /> +<p>No longer librewolf.</p> +<p>Start WireShark. Open LibreWolf. That is unacceptable. This is arguably worse than Brave. Brave contacts their updating servers for extensions, variations server, and seemingly their standard updating server. I dislike this, but it’s not as bad as the default librewolf.</p> +<p>Brave doesn’t allow users to disable this.</p> +<hr /> +<p>Maybe librewolf?</p> +<p>default startup dns resolutions:</p> +<blockquote> +<p>5 2.306344381 192.168.1.9 192.168.1.1 DNS 95 Standard query 0x38d6 A content-signature-2.cdn.mozilla.net 6 2.306350938 192.168.1.9 192.168.1.1 DNS 95 Standard query 0xc9d0 AAAA content-signature-2.cdn.mozilla.net 7 2.307211964 192.168.1.1 192.168.1.9 DNS 111 Standard query response 0x38d6 A content-signature-2.cdn.mozilla.net A 34.160.144.191 8 2.307699875 192.168.1.1 192.168.1.9 DNS 123 Standard query response 0xc9d0 AAAA content-signature-2.cdn.mozilla.net AAAA 2600:1901:0:92a9:: 38 2.394069350 192.168.1.9 192.168.1.1 DNS 97 Standard query 0xc18c A firefox.settings.services.mozilla.com 39 2.394075315 192.168.1.9 192.168.1.1 DNS 97 Standard query 0x978f AAAA firefox.settings.services.mozilla.com 40 2.398144317 192.168.1.1 192.168.1.9 DNS 149 Standard query response 0xc18c A firefox.settings.services.mozilla.com CNAME mozilla.map.fastly.net A 146.75.81.91 41 2.398665207 192.168.1.1 192.168.1.9 DNS 161 Standard query response 0x978f AAAA firefox.settings.services.mozilla.com CNAME mozilla.map.fastly.net AAAA 2a04:4e42:84::347 103 3.020292741 192.168.1.9 192.168.1.1 DNS 85 Standard query 0x45e4 PTR 91.81.75.146.in-addr.arpa 104 3.020358823 192.168.1.9 192.168.1.1 DNS 87 Standard query 0x2e19 PTR 191.144.160.34.in-addr.arpa 105 3.021571021 192.168.1.1 192.168.1.9 DNS 85 Standard query response 0x45e4 No such name PTR 91.81.75.146.in-addr.arpa 106 3.022490501 192.168.1.1 192.168.1.9 DNS 140 Standard query response 0x2e19 PTR 191.144.160.34.in-addr.arpa PTR 191.144.160.34.bc.googleusercontent.com</p> +</blockquote> +<p>That’s not acceptable..</p> +<p>Moreover opening a new session creates this connection:</p> +<blockquote> +<p>191.144.160.34.bc.googleusercontent.com.:443</p> +</blockquote> +<p>This is known to be associated with …</p> +<p>This is not fine. This can be disabled with disabling push notifications, but that sucks.</p> +<p>https://www.reddit.com/r/LibreWolf/comments/15hs76o/outgoing_connection_bc_googleusercontent_com/</p> +<p>This can be disabled with ublock / your dns server, but the best way is probably to set the following to fals:</p> +<p>dom.webnotifications.enabled</p> +<p>dom.webnotifications.serviceworker.enabled</p> +<p>dom.push.connection.enabled</p> +<p>dom.push.enabled</p> +<hr /> +<p>mullvad:</p> +<ul> +<li>no dns resolutions on startup</li> +<li>no connections started prior to searching anything</li> +<li>no connections when typing into search bar +<ul> +<li>link for why this is good</li> +</ul></li> +<li>usable +<ul> +<li>in general, I haven’t found sites to becoming broken</li> +</ul></li> +</ul> +<hr /> +<ul> +<li>fingerprinting? +<ul> +<li>does it warrant not blocking outbound connections?</li> +</ul></li> +</ul> +<hr /> +<p>Mullvad win:</p> +</body> +</html> diff --git a/posts/site_wip/the-big-three-privacy-search-engines.html b/posts/site_wip/the-big-three-privacy-search-engines.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>the-big-three-privacy-search-engines</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="the-big-three-privacy-search-engines">The Big Three (Privacy) Search Engines</h1> +<p>The big three privacy search engines are 1) Brave Search 2) DuckDuckGo 3) Startpage. These are the most popular privacy search engines because they generally provide sensible enough results, have privacy policies that aren’t anti-consumer, and make sensible technical decisions that are verifiable by looking at the requests browsers make to their search engines to minimize tracking.</p> +<h2 id="indices">Indices</h2> +<p>Brave Search uses its own index.</p> +<p>DuckDuckGo primarily uses Bing.</p> +<p>Startpage primarily uses Google.</p> +<h2 id="quality-comparison">Quality Comparison</h2> +<h2 id="ip-rotation-and-browser-fingerprint">IP Rotation and Browser Fingerprint</h2> +<p>Every day I switched exit nodes using the protonvpn cli. I also cleared all cached data from librewolf at the end of the day.</p> +</body> +</html> diff --git a/posts/site_wip/the-case-against-verification.html b/posts/site_wip/the-case-against-verification.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>the-case-against-verification</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="the-case-against-verification">The case against verification</h1> +<ul> +<li><p>llms can cause ppl to rely on them to fact check / review at the end -&gt; worse checking themselves -&gt; inability to check themselves</p></li> +<li><p>vet?</p></li> +<li><p>consensus.ai</p></li> +</ul> +<p>Motivated by this: gemini://sakugadiscofun.site/gemlog/2026-07-16-on-ai-usage.gmi</p> +</body> +</html> diff --git a/posts/site_wip/the-legality-of-summarization.html b/posts/site_wip/the-legality-of-summarization.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>the-legality-of-summarization</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="the-legality-of-summarization">The Legality of Summarization</h1> +<p>Warning: Discussion of AI Content Note: AI has <strong>not</strong> been used in the writing process, but I dislike reading things that discuss AI so be warned, this will discuss AI and related concepts.</p> +<p>There have been prior court cases around using snippets of indexed web content in search engines, to set precendents about their usage wrt copyright holders. Given that these snippets don’t impact the authors by subverting earnings potential, they were deemed acceptable. Does this precedent still apply for AI summaries?</p> +</body> +</html> diff --git a/posts/site_wip/tracking-lifts.html b/posts/site_wip/tracking-lifts.html @@ -0,0 +1,155 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>tracking-lifts</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="tracking-lifts-how-i-broke-a-years-long-plateau-and-became-an-intermediate-lifter">Tracking Lifts (How I Broke a Years Long Plateau and Became an Intermediate Lifter)</h1> +<h2 id="levels-of-lifter">Levels of Lifter</h2> +<p>A few definitions by layer</p> +<h3 id="time-based">Time-based</h3> +<ul> +<li>Beginner +<ul> +<li>0 - 2 years</li> +</ul></li> +<li>Intermediate +<ul> +<li>3 - 6 years</li> +</ul></li> +<li>Advanced +<ul> +<li>7+ years</li> +</ul></li> +</ul> +<p>These aren’t 100% agreed upon, and some may argue advanced might be 3+ years. Simply going to the gym doesn’t mean someone understands how to lift weights, even if they’ve gone for a long time. On average, you can expect people who have been lifting for longer to be more experienced, but this isn’t perfect.</p> +<h3 id="metric-based">Metric-based</h3> +<p>The big three are sometimes used to group categories of lifters based on % of bodyweight their 1RM is for the given lift. Below are rough guidelines for bench press:</p> +<ul> +<li>Beginner +<ul> +<li>0% - 100% of bodyweight</li> +</ul></li> +<li>Intermediate +<ul> +<li>100% - 150% of bodyweight</li> +</ul></li> +<li>Advanced +<ul> +<li>150+% of bodyweight</li> +</ul></li> +</ul> +<p>These can be argued, and to make this more accurate you can group individuals by age range, but even this is limited. There are many roided out individuals in my age group who don’t really understand lifting, are blasting anabolic steroids, and can easily outlift me on the bench, but I’d argue these individuals are not as advanced as I am in the gym.</p> +<h3 id="experience-based">Experience-based</h3> +<p>My preferred definitions for beginner, intermediate, and advanced are as follows:</p> +<ul> +<li>Beginner +<ul> +<li>Evident improvements month to month without the requirement of programming changes</li> +</ul></li> +<li>Intermediate +<ul> +<li>Broken through their first lifting plateau via programming changes</li> +</ul></li> +<li>Advanced +<ul> +<li>Everything has to be dialed in to gain muscle</li> +</ul></li> +</ul> +<h2 id="my-story">My Story</h2> +<p>My age is between 22 and 27. I started lifting weights when I was 12 when my father gave me a rudimentary PPL-esque workout plan. Inspired by Youtube’s weightlifting scene (I specifically remember the hodge twins, connor murphy, and rich piana from that time period) I stuck to that</p> +<p>I stuck to this plan for a few months before stopping. I don’t remember the specifics of this, but it’s likely my consistent schedule got interrupted and I simply didn’t get back to it. After a nudge from my father to get back into it a few months later, I started lifting weights again. From that point on, to the best of my knowledge, the largest number of consecutive days I didn’t do strength training was 2.</p> +<p>A few years ago I started adding exercises to the core set my father prescribed as part of my plan, but prior to that I had religiously stuck to the plan.</p> +<p>A month ago I realized I’d spent the past few years only improving marginally. I couldn’t quantify the amount I was improving, but it was very minimal. I realized this when I went for a 225 1RM again after first hitting 6 months prior and barely eeking it out again. I suspect most of the gains I got in the past few years was going from a home gym to a commercial gym which also forced me to make my sessions more concise. This resulted in a cut in rest times between sets along with an increase in volume. This likely broke a plateau, but I didn’t realize this at the time, and the plateau was just pushed up slightly higher.</p> +<p>Since I didn’t consciously identify the plateau at the time, I can’t say this was me breaking into the intermediate lifter category. I did identify the plateau when doing the second 1RM of 225 though. The reason I was able to identify this was because I remembered a prior weight I did. After this, I decided to start tracking all of my lifts.</p> +<p>Over the past few months, this has led to sizeable lifting gains, and an increase in my effort to match or beat prior comparable sets.</p> +<h2 id="enhanced-self-is-the-enemy-of-a-good-life">Enhanced Self is the Enemy of a Good Life</h2> +<p>Despite these improvements from tracking, tracking my BP has decreased my quality of life. As such, I stopped doing this after a few weeks. Tracking my blood pressure only served to stress me out for no good reason because my BP was always healthy except when I would get nervous about my BP reading being elevated, which would then happen, but this was never dictated by diet, and always dictated by thought. (draw parallel to sleep).</p> +<p>To this end, I think it’s only a good idea to track things that 1) help you improve your performance 2) actually matter.</p> +<ul> +<li>tracking porn +<ul> +<li>https://www.bradstulberg.org/p/the-enhanced-self-is-the-enemy-of</li> +</ul></li> +</ul> +<hr /> +<ul> +<li>what to track? +<ul> +<li>things you can change +<ul> +<li>I can change my weight / bp, but like really? +<ul> +<li>probably not a good idea</li> +</ul></li> +<li>track things latently? +<ul> +<li>only after things will be noticed should I track them?</li> +<li>what about only things that are incremental? +<ul> +<li>perhaps this?</li> +<li>like if you are moving towards a pr then maybe track that +<ul> +<li>track the most important stuff? +<ul> +<li>like no one cares about slowest mile probably, maybe just like start to end?</li> +</ul></li> +</ul></li> +</ul></li> +</ul></li> +</ul></li> +</ul></li> +</ul> +<blockquote> +<p>Until recently, you received health metrics once a year at your annual physical. You understood your social circle based on the number of people who showed up at weddings, birthdays, and holiday parties. Professional success was measured on yearly lists. Athletes knew where they ranked based on a few events they peaked for every season. We still measured and compared, but there were long stretches of time between those measurements and comparisons. And in those long stretches of time, we could forget about ourselves and how we stacked up. That is no longer the case.</p> +</blockquote> +<p>This made me think we should only track things on longer timescales or perhaps only non-digitally. I think the ladder is likely incorrect, and merely a facilitator of the former. that said, I do think there’s some merit to the former. Perhaps its short term tracking of things that are weakly correlated? Like it seems fine to track lifting because in the short term it’s highly correlated. But something like blood pressure is much more stochastic, as is sleep. You don’t really get very very good at sleep and then get huge amounts of it over time, it’s a test each time. If it’s a test each time, it shouldn’t be tracked that frequently. This holds for the bp and other tests as well.</p> +<p>This also allows longer term tracking of bp and body weight which will miss the arbitrary fluctutations. When lifting there are very small fluctuations over time so it seems permissible to track. This might also be that bullshit rationalist thing where you decide on something and then try to find a reason for you to do it. I want to make shit tons of money -&gt; this is good for the world because I can give it away so I would be stupid not to.</p> +<p>Or perhaps it’s this: If there are any consequences to tracking, like taking some non-trivial amount of time, increasing stress, perhaps degrading biomarkers, do it sparsely.</p> +<blockquote> +<p>orthosomnia</p> +</blockquote> +<p>Worsening of sleep due to tracking</p> +<hr /> +<p>General rule: If the cost of tracking something is greater than the benefits, don’t do it.</p> +<p>If it stresses you out unduly, don’t track it. If it takes a lot of time, don’t track it. If it degrades the biomarker, don’t track it.</p> +<hr /> +<blockquote> +<p>Maslow used the term peak experience to capture transcendent moments of joy, awe, and deep fulfillment</p> +</blockquote> +<blockquote> +<p>The inverse is also true: studies show that an excessive focus on the self is associated with choking, be it on the playing field, in the boardroom, or in the bedroom. Look more broadly across all of life, and research shows excessive self-focus is linked to unhappiness, anxiety, and depression.</p> +</blockquote> +<hr /> +<p>Prescription: Write it down and don’t give a shit. When will you give a shit? Some amount of time later. A month, a week, a year, whatever, but it isn’t now. At that point look back and see how things have gone.</p> +<p>High Level: Check them less frequently.</p> +<p>Perhaps only track lifts once every other week? This would be some sort of mesocycle tracking.</p> +</body> +</html> diff --git a/posts/site_wip/what-i-want-from-a-vcs.html b/posts/site_wip/what-i-want-from-a-vcs.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>what-i-want-from-a-vcs</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="what-i-want-from-a-vcs">What I Want From a VCS</h1> +<p>Similar to Luke Smith’s blog post about browsers [1], I would like to put forth what I want from a VCS. Currently, no VCS meets all of my requirements for it to be considered good.</p> +<p>Here is a list of VCS’s in consideration. If there are additional ones I am missing that are free software (a requirement for it to even be considered ethical to use) and reasonable enough to be compared, please email me.</p> +<ul> +<li>Git</li> +<li>Mercurial</li> +<li>Subversion (SVN)</li> +<li>Fossil</li> +<li>Darcs</li> +<li>Revision Control System</li> +<li>CVS</li> +<li>SCCS</li> +<li>Pijul</li> +<li>JJ</li> +</ul> +<h2 id="cutting-down-the-list">Cutting Down The List</h2> +<ol type="1"> +<li>The VCS can’t allow rewriting history</li> +</ol> +<p>The purpose of a VCS is to track the history of files. If the history of files can be rewritten it both makes the state at a given time confusing, and defeats the purpose of using a VCS.</p> +<p>Disqualifies:</p> +<ul> +<li>Git (Rebase)</li> +<li>JJ</li> +<li>Fossil</li> +<li>Mercurial</li> +<li>Darcs</li> +</ul> +<p>Allows:</p> +<ul> +<li>CVS</li> +<li>SVS</li> +<li>SCCS</li> +<li>RCS</li> +</ul> +</body> +</html> diff --git a/posts/site_wip/what-is-a-lockscreen.html b/posts/site_wip/what-is-a-lockscreen.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>what-is-a-lockscreen</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="the-humble-lock-screen">The Humble Lock Screen</h1> +<p>Lock screens are used to limit access to a system by requiring a user to perform a ritual. These rituals can be arbitrary so long as the individuals capable of the ritual are the set of individuals you’re okay with using the system.</p> +<p>As of writing this, I use <a href="https://github.com/dannyfiresnake/xl">xl</a> as my lock screen. I started using this because I wanted my awesome background to display when my screen was locked, and after learning how X11 lock screens actually work, I realized the simplest way that’d suffice for me is to have the root window consume pointer and keyboard inputs via XGrabPointer and XGrabKeyboard respectively. Now I just swap DWM tags to a tag with no windows and press Mod4 and XK_l.</p> +<h2 id="formalization">Formalization</h2> +<p>A proper ritual for accessing a system fulfils the following requirement:</p> +<p><span class="math inline"><em>r</em> ∈ (<em>A</em><sub><em>i</em></sub> ∩ <em>B</em><sub><em>i</em></sub> ∩ ... ∪ <em>Z</em><sub><em>i</em></sub>) − <em>Γ</em><sub><em>i</em></sub></span></p> +<p>Where <span class="math inline"><em>A</em><sub><em>i</em></sub>, <em>B</em><sub><em>i</em></sub>, ..., <em>Z</em><sub><em>i</em></sub></span> are the sets of individuals who should be able to perform the ritual to access the system, and <span class="math inline"><em>Γ</em><sub><em>i</em></sub></span> is the collective intelligence of all individuals who shouldn’t have access to the system.</p> +<p>In the case of multi-user system’s it’s often useful to have one ritual per-person to simplify the process of creating a shared ritual, and for traceability.</p> +<p>Notably, to fulfil the ritual, one mustn’t be interrupted. Given this, time based rituals may be permissible in certain contexts. Things like proof of work, solving trivial problems, typing tests, and other things that are subject almost exclusively to time deltas can be rituals, assuming the amount of time it takes to perform the ritual is greater than the amount of time required to stop someone else from completing the ritual who isn’t in the user set.</p> +<h2 id="uncommon-rituals">Uncommon Rituals</h2> +<p>Common rituals are passwords, biometrics, hardware keys, stuff like that. Uncommon ones, similar to what some use with their morning alarms, can perhaps be questions. If you are quite skillful at some set of problems, and are willing to solve them each time you are to unlock your system, these may be used in lieu of passwords, as long as they are rather complex.</p> +<p>Another consideration is time. If I lock my screen, I’ll generally be very close to my system while it’s locked because I don’t trust any lock screens that aren’t actually logging out my user account, which don’t seem to really exist in a sensible way. Given this, for me it’d actually be sensible to just have a small set of problems to solve that take some non-trivial amount of time that’s larger than the amount of time I’ll be away from my system.</p> +<p>Another layer of protection I have in the time cost domain is my keyboard, split, colemak.</p> +<h3 id="knowledge">Knowledge</h3> +<p>An interesting solution to this problem is using knowledge. There are things about me my wife knows, things about me specific family members of mine know, and specific pieces of information about me friends know. Given these considerations, if I wanted my system to be accessible to multiple people, the selection of a ritual could be done on the basis of the union or our knowledge, differenced from the knowledge of everyone outside of the group.</p> +<h3 id="optimization">Optimization</h3> +<p>We may want to optimize for time. Such an optimization likely dictates biometrics are to be used as the ritual, and every person who accesses the system will have their own ritual. If we are optimizing for fun or improvement, or some other objective there are far more options.</p> +<h4 id="fun">Fun</h4> +<ul> +<li>Video games</li> +</ul> +<h4 id="improvement">Improvement</h4> +<ul> +<li>Typing tests</li> +<li>Competitive programming</li> +<li>Math</li> +<li>Logic</li> +<li>Vim tutor</li> +</ul> +</body> +</html> diff --git a/posts/site_wip/what-makes-good-software.html b/posts/site_wip/what-makes-good-software.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>what-makes-good-software</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<p>Good software is made by people who are motivated to solve a problem.</p> +<p>Money isn’t the problem, it’s extrinsic motivation which often creeps in when there is money, but not always, but large corporations often excacerbate these issues too. Gitea makes money, but they don’t appear to be immoral soo…..</p> +</body> +</html> diff --git a/posts/site_wip/why-people-build-spyware.html b/posts/site_wip/why-people-build-spyware.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>why-people-build-spyware</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="why-people-build-spyware">Why People Build Spyware?</h1> +<h2 id="date-2025105">Date: 2025/10/5</h2> +<p>I will argue the main driver behind people building spyware is apathy.</p> +<h2 id="the-real-world-vs.-the-digital-world">The Real World vs. The Digital World</h2> +<p>Yesterday I was following a person from my apartment complex around because I wanted to know what he did for work. It was quite interesting, he works at a restaurant and I learned some new recipes by watching him cook. It’s nice being able to watch people when they don’t know they’re being watched.</p> +<p>Wait, no, I didn’t do that, because that’s creepy. What I actually did is added PostHog telemetry to my website to track how users are navigating my website, what they click on, where their mouse goes, their keystrokes, all that. Wait, I didn’t do that either because it’s equally as creepy.</p> +<p>It is far more palatable for most developers to add input and page navigation tracking to a website than to tail someone in real life. In both cases, you are observing someone who doesn’t know they are being observed and likely doesn’t want to be observed. This leads me to conclude that if one is not acceptable, neither are.</p> +<p>So why is it palatable to add site tracking? Because it is in the digital world, not the real world. When people are just numbers on a screen and users of software you developed, they are often viewed as less than people. Why does it matter that I know what user 2109478 did on my website? I made the website, I’m the creator of the website, they chose to use my site, don’t they know the consequences of that? This framing removes any guilt associated with developing spyware and thrusting it upon people.</p> +<h2 id="what-can-be-done">What Can Be Done?</h2> +<p>If you are developing software, say no to tracking. I am guilty of transgressions myself, but please consider the consequences of the tracking you add to your software and consider if it would be reasonable to collect this data in person. If it isn’t, why is it okay to collect this data online?</p> +<p>If you are using software that has trackers, ask yourself why. Would you be willing to have someone sitting behind you collecting this information? If not, don’t put up with it. If the software is libre, make the changes yourself to write these wrongs and re-distribute it to anyone who will use it. If the software is non-libre (proprietary), use not an “alternative” [1] to it, but an improvement upon it in the form of libre software. If no such software exists, ask yourself why that is. Could you build a libre improvement upon it? Why is it you need to use this software in the first place? Does your the task you are trying to achieve supersede the value of privacy and the immorality of proprietary software?</p> +<h2 id="citations">Citations</h2> +<p>[1] - https://www.gnu.org/philosophy/words-to-avoid.html#Alternative</p> +</body> +</html> diff --git a/posts/site_wip/why-us-software-sucks.html b/posts/site_wip/why-us-software-sucks.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>why-us-software-sucks</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="why-us-software-suck">Why US Software Suck</h1> +<p>Let’s compare some EU software companies with US software companies.</p> +<h2 id="eu">EU</h2> +<ul> +<li>Email +<ul> +<li>Tuta Nota</li> +<li>Proton</li> +<li>Mailbox</li> +<li>Posteo</li> +</ul></li> +</ul> +<h2 id="us">US</h2> +<ul> +<li>Email +<ul> +<li>Microsoft</li> +<li>Google</li> +</ul></li> +</ul> +<h2 id="explanation">Explanation</h2> +<p>These lists are non-exhaustive, but it tends to be the case that the most popular services coming from the EU for a given product segment are privacy respecting whereas the same is not true for US based countries. Why might this be?</p> +<h3 id="love-of-the-game">Love of the Game</h3> +<p>Average salary comparison. Shows people choose it out of passion more than out of greed</p> +<h3 id="privacy-laws">Privacy Laws</h3> +<p>They have privacy laws that impact companies substantially, to the extent that they simply position themselves as privacy respecting, and often walk the walk, because it can be too costly to be a POS company like google in the EU.</p> +<h3 id="culture">Culture</h3> +<p>US has greedy startup BS culture sometimes.</p> +</body> +</html> diff --git a/posts/site_wip/wikipedia-and-truth-on-the-internet.html b/posts/site_wip/wikipedia-and-truth-on-the-internet.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>wikipedia-and-truth-on-the-internet</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="truth-on-the-internet">Truth on the Internet</h1> +<h2 id="claim">Claim</h2> +<p>Wikipedia is an okay source for purely factual information like mathematical topic, CS topics, etc., but it is not a good source for other kinds of information. Similarly, there are other internet sources that are good for academic information, but there is a lack of rigor in most other topics.</p> +<h2 id="reasoning">Reasoning</h2> +<p>Wikipedia has been a good source of information on computer science and math topics for me. In general, articles are correct and I appreciate the formatting of the site working in my preferred web browser, lynx. When it comes to more subjective topics, it has not been a very good source for me. This also applies to the broader internet as well, albeit it is not consistently good on academic topics.</p> +<h3 id="gemini">Gemini</h3> +<p>Consider the Gemini protocol article on Wikipedia [1]. Most of the information in the article is acceptable, discussing actual information about the protocol, its history, and other related concepts, but the reception section is quite problematic. I will allow you to read it yourselves.</p> +<blockquote> +<p>Gemini is praised for its simplicity but criticized for “excluding people who use ordinary web browsers”. Gemini’s usefulness has been said to be “dependent on the kinds of content available on Gemini and whether it appeals or not”. Stéphane Bortzmeyer has said Gemini is retro but with modern features. Daniel Stenberg reviewed the 0.16.1 protocol spec, and criticized it as weak on security (Trust on first use) and slow in performance (short-lived bursty TCP connections) if it was ever used to transfer resource heavy HTML pages.[13] Gemini pages are usually downloaded as gemtext only without requesting fonts or linked resources such as images.</p> +</blockquote> +<p>Let’s break down a few things.</p> +<h4 id="gemini-excludes-people">Gemini Excludes People</h4> +<blockquote> +<p>Gemini is praised for its simplicity but criticized for “excluding people who use ordinary web browsers”.</p> +</blockquote> +<p>A correction to this may be “it was once criticized by an individual for being exclusive, but said individual was misinformed”. The only exclusion that is happening is browser makers do not support the protocol. There is no reason a normal web browser can’t support Gemini, and no one who is developing the gemini protocol pushes back against its adoption in major web browsers.</p> +<p>Such a criticism is similar to criticizing HTTP because none of the Gemini browsers support it. Gemini is an exceptionally easy protocol to implement and to criticize it for exclusivity is a bit silly.</p> +<h4 id="security-concerns">Security Concerns</h4> +<blockquote> +<p>Daniel Stenberg reviewed the 0.16.1 protocol spec, and criticized it as weak on security (Trust on first use)</p> +</blockquote> +<p>I view his first criticism as a selling point of Gemini. TOFU is how I believe the internet should work, or maybe DANES, but certainly not CAs. CAs are antithetical to the spirit of the internet. The internet is supposed to be free of authorities, but when CAs are considered the authority on who is able to host a website with HTTPS, which is functionally a necessity to have a voice on the internet, we do have arbiters of who can speak, and we lose freedom.</p> +<p>I think the term CA is a misnomer because there is nothing authoritative about CAs, and there is no authority on the internet. Furthermore, there have been many CA incidents in the past [2] [3], which is to be expected when authorities are appointed.</p> +<h4 id="slowness">Slowness</h4> +<blockquote> +<p>slow in performance (short-lived bursty TCP connections) if it was ever used to transfer resource heavy HTML pages.[13] Gemini pages are usually downloaded as gemtext only without requesting fonts or linked resources such as images.</p> +</blockquote> +<p>I seem to be missing something here. A sportscar is slow when it is towing a tree up a hill, but that doesn’t make a sportscar slow. If the Gemini protocol were saddled with the burden of HTML then yes, it would be slow, but that’s the thing, it’s not. It’s made for gemtext not HTML/JS soydevery.</p> +<h3 id="youtube-video-uploading-metrics">YouTube Video Uploading Metrics</h3> +<p>YouTube video upload metrics are what prompted me to write this post. I was doing research for a project where I wanted to determine how long YouTube’s business model of not deleting any videos on the platform, apart from those breaking ToS, could be sustained [4]. I started with a duckduckgo search and the top search result claimed that in February 2025 2.6 million videos were uploaded every day [5]. This cite then linked to another site [6] which made no such assertion. I returned to the original site to realize I’d been tricked. I should’ve known the domain SEO.ai was an AI slop SEO farming site, but it was the top one. I then went to Google to see what results I would get there. The same result showed at the top, but this time I got an AI summary which stated the exact same hallucinated claim.</p> +<p>Truth can’t be found on the open web anymore. There are too many layers of nonsense. We have an AI summarizing an AI that summarized an unsubstantiated blog post that didn’t even make the claim the first AI summary thought it did.</p> +<h2 id="what-can-be-done">What Can Be Done</h2> +<p>At present, we can stop, or limit, our usage of search engines. I plan to replace search engines with going directly to sites that I know are useful, using RSS, and trying to reference books as much as possible. It’s modestly disappointing, but good options are lacking right now. If you have any thoughts on this, feel free to email me!</p> +<h2 id="sources">Sources</h2> +<p>=&gt; https://en.wikipedia.org/wiki/Gemini_(protocol) Gemini Protocol Wikipedia Article =&gt; https://en.wikipedia.org/wiki/DigiNotar CA Hacked =&gt; https://sslmate.com/resources/certificate_authority_failures Even More CA Issues =&gt; gemini://blog.laack.co/sustainability-of-youtube.gmi The Sustainability of YouTube =&gt; https://web.archive.org/web/20250814122654/https://seo.ai/blog/how-many-videos-are-on-youtube AI Summary of an AI Summary =&gt; https://web.archive.org/web/20250304100048/https://photutorial.com/how-many-videos-on-youtube/ AI Summary of a Poorly Researched Blog Post</p> +</body> +</html> diff --git a/posts/site_wip/will-inference-costs-come-down.html b/posts/site_wip/will-inference-costs-come-down.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>will-inference-costs-come-down</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="will-inference-costs-come-down">Will Inference Costs Come Down?</h1> +<h2 id="date-20250119">Date: 2025/01/19</h2> +<h2 id="context">Context</h2> +<p>I have seen a sentiment that the cost of inference will come down quickly over time. This sentiment will dictate what some startups build. If one expects the cost of inference to fall rapidly, making your product cost effective isn’t a concern at present, in the future tokens will be very cheap so might as well build systems that use lots of tokens to generate exceptional results instead of being conservative with tokens while maintaining adequate results. Even if one expects prices to fall over time, there are still near term capitalization opportunities, but the upside for these opportunities may be limited.</p> +<p>Conversely, one may expect the price of inference to increase over time because the big players are subsidizing usage right now [1], but this will not be sustainable over longer timescales.</p> +<h2 id="citations">Citations</h2> +<p>[1] - [2] - <a href="https://web.archive.org/web/20260117001407/https://openai.com/api/pricing/">https://web.archive.org/web/20260117001407/https://openai.com/api/pricing/</a> [3] - <a href="https://web.archive.org/web/20260119083924/https://claude.com/pricing#api">https://web.archive.org/web/20260119083924/https://claude.com/pricing#api</a></p> +</body> +</html> diff --git a/posts/site_wip/yes-software-does-get-completed.html b/posts/site_wip/yes-software-does-get-completed.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>yes-software-does-get-completed</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="yes-software-does-get-completed">Yes, Software Does Get Completed</h1> +<p>Not all software needs to be maintained forever, and that’s fine. Feature completness does exist. Please stop adding features. I don’t want more features. I want simplicity. I want software that is like lego blocks. Each piece doing one thing and one thing only, fitting together in harmony. Please stop adding features.</p> +</body> +</html> diff --git a/posts/site_wip/you-are-being-tricked.html b/posts/site_wip/you-are-being-tricked.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>you-are-being-tricked</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="you-are-being-tricked">You Are Being Tricked</h1> +<p>You are being tricked into thinking new things are useful.</p> +<p>Sense of novelty wears off, leads back to the same position you were in before.</p> +<p>Shit like obsidian, notion, and all these other spywares make you think you are being productive and stuff, but you really aren’t, and even at this, once you become productive with them, you realize vim is still what you should be using.</p> +</body> +</html> diff --git a/posts/site_wip/your-arrogance-is-their-bet.html b/posts/site_wip/your-arrogance-is-their-bet.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>your-arrogance-is-their-bet</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="your-arrogance-is-their-bet">Your arrogance is their bet</h1> +<p>Are you so arrogant to believe that you haven’t obviate yourself, or are othewise in the process of doing so by using language models?</p> +<h2 id="taken-away">Taken away</h2> +<p>Do you believe they will actually let you use the tool once it’s better than you? Once it can do everything you can, they will take access away. The endgame can’t possibly be for these companies to just sell inference; they must 1) make models that are more valuable than human labor 2) reap the sole economic reward of these models. If they have to share in the economic value, the math doesn’t make sense.</p> +</body> +</html> diff --git a/posts/site_wip/your-gemini-search-engine.html b/posts/site_wip/your-gemini-search-engine.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc 3.10.2" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>your-gemini-search-engine</title> + <style> + /* Default styles provided by pandoc. + ** See https://pandoc.org/MANUAL.html#variables-for-html for config info. + */ + span.smallcaps{font-variant: small-caps;} + div.columns{display: flex; gap: 1.5em;} + div.column{flex: auto;} + @media screen { + div.columns{gap: min(4vw, 1.5em);} + div.column{overflow-x: auto;} + } + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} + ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; + } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="your-gemini-search-engine">Your Gemini Search Engine</h1> +<p>The current Gemini search engines are decent. Given how small Geminispace is, I wondered how reasonable it would be for anyone to create and run their own search engine. Modern computers are quite performant and all that. This is my exploration of that idea.</p> +<h2 id="section"></h2> +</body> +</html> diff --git a/posts/wip/(how-to)-profile-your-software.md b/posts/wip/(how-to)-profile-your-software.md @@ -1,326 +0,0 @@ -# (How to) Profile Your Software, Part 1: CPU Go Brrr - -I recently started working on a browser for the [Gemini protocol](https://geminiprotocol.net/) called [foreseen](https://git.laack.co/foreseen/file/README.html) because I was annoyed with how slow most Gemini browsers are on low end hardware. This is a rather sad state of affairs because the Gemini protocol is extremely simple, with no support for dynamic layouts or styling. Given this, I believe everyone should perform at the very least some performance profiling before releasing it. Let's get into it. - -## Tools - -[Perf](https://en.wikipedia.org/wiki/Perf_%28Linux%29) is your friend. Unfortunately, only one of the three most popular operating systems (Linux, OpenBSD, FreeBSD) supports perf, but there are sufficient analogs on FreeBSD, and if you're on OpenBSD good luck. - -You might also want a visualization tool. I'll be showing [flamegraph](https://github.com/brendangregg/FlameGraph). Normally I just use perf because [it is very powerful](https://www.brendangregg.com/perf.html), but having pleasing visuals is useful for demonstrations (newer versions of `perf` can also generate flamegraphs directly, but they aren't as aesthetic). - -## Reading a flamegraph - -Let's start with something easy, how do you read a flamegraph? Take a look at the following flamegraph and, without my help, try to understand what's being shown: - -file:///home/andrew/gitRepos/blog/perf/ex1-fg.svg - -The amount of time spent with the `main` function on the stack is represented by the width of its bar. - -Notice how there are multiple bars that say `square`. This is because we execute `square` at different stack depths, and the width of each bar is dictated by the amount of time we spent with `square` on the call stack at a given stack depth. - -Given how the widths are calculated, we can deduce the top-down width of a bar is how much time the program spent executing a specific function. In the case of `squareHelper` and `square`, we see we spent more time executing `squareHelper` than `square`, evidenced by the fact that from a top-down view, `squareHelper` is wider. - -The astute among you might've noticed that `square` and `squareHelper` appear to sometimes be executed outside of the main loop. This is due to how stack depth is calculated, and that's a bit more technical than I'll be able to discuss here. - -## Perf - -I've been a little loose with my words thus far in describing flamegraphs. The command I've been using with perf to generate the data for flamegraphs isn't tracking the amount of time spent with a function on the stack at a given depth, we are instead tracking the number of on-CPU samples taken with the function on the top of the call stack. This distinction is important because things like blocking I/O will not be reflected in our timings. Additionally, since perf is interrupt based, it may miss some data, but it gives a good enough approximation of CPU utilization. - -``` -perf record -g ./ex1 -``` - -This is the command I ran to generate the data for the flamegraph. The `record` command is used to record events that will be written to the `perf.data` file. By default, `perf record` will sample at 1000Hz. The final option, `-g`, is used to specify we are interested in having the call stack included in our data. - -If you want to generate a flamegraph right away, you can run the following command: - -``` -perf script report flamegraph -``` - -This isn't how the flamegraph above was generated because I prefer Brendan's FlameGraph program, but both are fairly similar, and in a pinch, `perf script report flamegraph` will work. A command I use more often to view performance is: - -``` -perf report -g -``` - -``` -+ 100.00% 0.00% ex1 ex1 [.] _start -+ 100.00% 0.00% ex1 libc.so.6 [.] __libc_start_main -+ 100.00% 0.00% ex1 libc.so.6 [.] call_init (inlined) -+ 100.00% 0.00% ex1 libc.so.6 [.] 0x00007f6302a27781 -+ 99.79% 39.46% ex1 ex1 [.] main -+ 34.97% 19.94% ex1 ex1 [.] squareHelper(unsigned int) -+ 29.99% 19.90% ex1 ex1 [.] square(unsigned int) -+ 21.61% 20.69% ex1 ex1 [.] factorial(unsigned int) -... -``` - -or if I'm curious to see function calling information: - -``` -perf report -g --stdio -``` - -``` -... -|--88.87%--main -| | -| |--19.84%--squareHelper(unsigned int) -| | | -| | --4.99%--square(unsigned int) -| | -| |--19.55%--factorial(unsigned int) -| | -| --10.07%--square(unsigned int) -| -|--5.02%--squareHelper(unsigned int) -| -|--4.98%--square(unsigned int) -| ---1.13%--factorial(unsigned int) -... -``` - -In many cases, I find the `--stdio` command a bit difficult to read because the report can get exceptionally wide for any non-trivial program (there are additional CLI options that can help with this), and such navigation in the terminal is difficult. - -The final thing I wanted to mention is if you just want high level information about your program's performance, this is a useful command: - -``` -perf stat ./ex1 -``` - -``` - Performance counter stats for './ex1': - - 0 context-switches:u # 0.0 cs/sec cs_per_second - 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second - 132 page-faults:u # 4.1 faults/sec page_faults_per_second - 32,436.48 msec task-clock:u # nan CPUs CPUs_utilized - 356,775 branch-misses:u # 0.0 % branch_miss_rate (88.89%) - 63,706,083,988 branches:u # 1964.0 M/sec branch_frequency (88.89%) - 134,126,037,336 cpu-cycles:u # 4.1 GHz cycles_frequency (88.89%) - 300,951,617,557 instructions:u # 2.2 instructions insn_per_cycle (88.89%) - TopdownL1 # 4.4 % tma_backend_bound - # 61.4 % tma_bad_speculation (88.89%) - # 0.0 % tma_frontend_bound (77.78%) - # 34.2 % tma_retiring (88.89%) - - 32.440411262 seconds time elapsed - - 32.234190000 seconds user - 0.002939000 seconds sys -``` - -This is the command I run most frequently when validating optimizations where the optimization is targeting a portion of the codebase with an outsized footprint. If the program is more uniformly expensive, `perf stat` is likely less useful than a full report / flamegraph. - - -## What to optimize - -Start with the functions that are costing the most CPU time. Often a very small number of functions take up the majority of the computation, and these are the ones worth optimizing. As it relates to optimization in this context, I don't expect most people to be hand coding assembly, and if you are, you already know all of this anyways. This is for the people just building normal software, consider what's costly and ask yourself two questions: - -1. Would it be possible to call this function less often -2. Would it be possible to make each call of this function perform less work - -Work is key for most optimization; cache friendliness is important, but what I really want from software I use is for it to not leave tons of performance on the table by using bad algorithms, performing unexpected / unnecessary copies, or calling functions (like draw functions) when they don't have to. - -## Amfora - -This is where it all started for me; I was working on my Gemini protocol browser and I wanted to benchmark it against a well known browser. Amfora states in the readme that it "aims to be the best looking Gemini client with the most features", and while I absotlutely detest the idea that more features means slower in all cases, they do have some features that make it slower*. Specifically, they have syntax highlighting and per character coloring, neither of which my browser has, instead opting for a simpler line based coloring approach which I believe still results in nice looking gemtext because it's all line based at the end of the day. - -(* They could've done coloring as a second pass perhaps to improve perceived performance, but I'd imagine that'd be more complex, and it would increase the time to having the finalized text displayed) - -I decided the first benchmark I was going to perform was a comparison between their performances when opening large files on my filesystem. This was quickly stopped when I realized amfora has a max file size limit of 2097152 bytes or ~2MB. That's curious, but alright then. Let's just make a file that's bigger than 1MB. - -This is a first pass at a direct comparison so I'm not going to make it the max size, and I'm not going to use a representative text, just a bunch of numbers. - -```python -with open("lf.txt", "w") as f: - for i in range(0,200000): - f.write(str(i) + "\n") -``` - -That should be good enough, the resulting file is ~1.3MB in size. - -I then ran following command: - -``` -perf stat amfora lf.txt - -Performance counter stats for 'amfora lf.txt': - - 0 context-switches:u # 0.0 cs/sec cs_per_second - 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second - 2,742 page-faults:u # 9306.7 faults/sec page_faults_per_second - 294.63 msec task-clock:u # nan CPUs CPUs_utilized - 1,052,499 branch-misses:u # 0.2 % branch_miss_rate (90.02%) - 575,712,764 branches:u # 1954.1 M/sec branch_frequency (89.14%) - 955,922,330 cpu-cycles:u # 3.2 GHz cycles_frequency (87.42%) - 2,669,651,845 instructions:u # 2.8 instructions insn_per_cycle (88.36%) - TopdownL1 # 6.7 % tma_backend_bound - # 24.9 % tma_bad_speculation (90.11%) - # 16.4 % tma_frontend_bound (79.92%) - # 52.0 % tma_retiring (90.37%) - - 0.473990805 seconds time elapsed - - 0.272938000 seconds user - 0.021266000 seconds sys - -``` - -This is quite unscientific because I simply Ctrl-C'd out once the first characters had rendered. Here's the same for foreseen: - -``` -perf stat foreseen lf.txt - - Performance counter stats for 'foreseen lf.txt': - - 0 context-switches:u # 0.0 cs/sec cs_per_second - 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second - 8,936 page-faults:u # 104842.2 faults/sec page_faults_per_second - 85.23 msec task-clock:u # nan CPUs CPUs_utilized - 209,148 branch-misses:u # 0.1 % branch_miss_rate (88.30%) - 176,970,330 branches:u # 2076.3 M/sec branch_frequency (88.29%) - 248,919,966 cpu-cycles:u # 2.9 GHz cycles_frequency (88.29%) - 736,194,375 instructions:u # 3.0 instructions insn_per_cycle (88.99%) - TopdownL1 # 3.9 % tma_backend_bound - # 29.7 % tma_bad_speculation (89.50%) - # 21.2 % tma_frontend_bound (77.84%) - # 45.2 % tma_retiring (88.33%) - - 0.354029324 seconds time elapsed - - 0.066861000 seconds user - 0.021186000 seconds sys -``` - -Of these metrics, the most comparable one is CPU cycles because they aren't spinning during the time it took me to react to the text having been rendered, but even so, this isn't a very good benchmark, and it's not something I'd post about. - -Since Amfora can highlight code, let's see how the performance comparse if we just add our python code block to the top of that file, and rename it to lf.gmi: - -``` -perf stat amfora lf.gmi - - Performance counter stats for 'amfora lf.gmi': - - 0 context-switches:u # 0.0 cs/sec cs_per_second - 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second - 900,174 page-faults:u # 12090.4 faults/sec page_faults_per_second - 74,453.35 msec task-clock:u # nan CPUs CPUs_utilized - 229,042,926 branch-misses:u # 0.4 % branch_miss_rate (88.94%) - 62,713,218,442 branches:u # 842.3 M/sec branch_frequency (88.85%) - 153,193,058,619 cpu-cycles:u # 2.1 GHz cycles_frequency (88.97%) - 306,159,421,078 instructions:u # 2.0 instructions insn_per_cycle (88.90%) - TopdownL1 # 0.6 % tma_backend_bound - # 97.8 % tma_bad_speculation (88.83%) - # -0.1 % tma_frontend_bound (77.86%) - # 1.7 % tma_retiring (88.91%) - - 28.983517177 seconds time elapsed - - 63.894262000 seconds user - 8.207151000 seconds sys -``` - -Woah, that's a lot slower. With foreseen there shouldn't be any difference because each line is treated ~ the same, so something's up here. Let's look at a flamegraph for this. - -file:///home/andrew/gitRepos/blog/perf/amfora-before.svg - -So 68.34% samples occurred while executing the GC, that's a bit surprising, even given how awful garbage collectors are. We also see that 25.47% of the time, most of the remaining time, is spent in the RenderGemini function. Of this, most of it is spent on concatstring3, a function under the hood that's used to concatenate strings. - -Here's where that'd be used in the function: - -``` -rendered += fmt.Sprintf("[%s]", config.GetColorString("preformatted_text")) + - buf + fmt.Sprintf("[%s:%s:-]\r\n", config.GetColorString("regular_text"), config.GetColorString("bg")) - -... - -rendered += buf + "\r\n" - -... - -rendered += ren - -... - -buf += strings.TrimSuffix(lines[i], "\r") + "\r\n" -``` - -Well, there's our problem; each of these seemingly innocuous appends is actually very costly. Unlike sensible OO / procedural programming languages, Go strings are immutable so each of these operations will create an entirely new string each time, and since we accumulate into `buf` until reaching a preformatted text switch line ("```" lines), the file we were trying to open has to re-create the full string 200,000 times, since we only have the tail 200,000 lines in the file don't have a format switcher. - - -This is relatively trivial to solve by using a strings.Builder which doesn't have this issue, and that's [what I did](https://github.com/makew0rld/amfora/pull/370/changes)*. After this change, we can perform our profiling again to find: - -(NOTE: The profiling I did to find this differed slightly from what's shown here, hence the difference in numbers between what we see now, and what's seen in the PR, but they're similar enough) - -``` -perf stat amfora lf.gmi - - Performance counter stats for 'amfora lf.gmi': - - 0 context-switches:u # 0.0 cs/sec cs_per_second - 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second - 6,039 page-faults:u # 4871.9 faults/sec page_faults_per_second - 1,239.55 msec task-clock:u # nan CPUs CPUs_utilized - 3,631,996 branch-misses:u # 0.1 % branch_miss_rate (89.02%) - 3,017,891,055 branches:u # 2434.7 M/sec branch_frequency (88.96%) - 4,654,531,574 cpu-cycles:u # 3.8 GHz cycles_frequency (88.93%) - 14,168,541,807 instructions:u # 3.1 instructions insn_per_cycle (88.81%) - TopdownL1 # 2.2 % tma_backend_bound - # 36.9 % tma_bad_speculation (88.80%) - # 18.5 % tma_frontend_bound (77.83%) - # 42.5 % tma_retiring (88.90%) - - 1.185772969 seconds time elapsed - - 1.193871000 seconds user - 0.039062000 seconds sys -``` - -Much better, that's now using 32x less cycles, and is far faster than before. - -file:///home/andrew/gitRepos/blog/perf/amfora-after.svg - -Looking again at the flamegraph, we see the RenderGemini function is now mostly performing word wrapping, and the GC is only utilizing the CPU during 16.48% of our samples, much better. - -We can go deeper into this if we'd like, but there are now 3 ~equally costly groupings, and as performance becomes more diffuse, optimizations will generally have a smaller amount of impact on perf, so we can leave this where it is. - -## Refutations - -I think everything above paints a picture that you don't have to put in that much effort to, in many cases, make things a lot better, and you don't have to be that well versed in optimization either. - -I often hear arguments about how we should just let other people make software and we'll just use it and be happy because they're smarter / better than us at it, this is often the case with libraries, and I so vehemently disagree with this idea. Amfora is a piece of software with 1.4K Github stars, that's existed for > 6 years with 54 contributors; it's not tiny, and yet a glaring issue took this long to find and solve. - -While I do think there is blame in this situation, I don't think there should be any shame in writing bad software, but it's all of our jobs to make our software a little less bad over time, hopefully you can do the same, and help others with that too. - -## What's Next - -Consider learning memory profiling next. I didn't directly discuss the topic because 1) it's more complex and 2) memory related performance issues often manifest, like we saw in the go example, as CPU performance issues too. I also didn't discuss anything related to instrumented profiling; everything I've shown with perf can be done without changing any code. When you can change the code, you have the ability to get more granular than just getting metrics on the basis of functions. Despite the upsides of instrumented profiling, I rarely do it because it often takes more time. The main context where I do it is to get shareable information with others, in a working context, and for intra-function profiling. - -Memory stuff is also more complex across languages, where they do weird stuff like go not using malloc. - ---- - - - ---- - -Memory utilization is missing from this; what's the recommendation? - -- massif - - heap analyzer w/ ability to analyze stack at great addl. cost - - doesn't work with go binaries? - - not directly, need --pages-as-heap=yes because it is just tracking malloc/free stuff - - LD_PRELOAD uses different malloc symbol ig - - massif-visualizer - - still gives unexpected results for go code. - - can give view into rss over time with --pages-as-heap=yes - - this makes it track mmap and such instead of just malloc - - slower, but more accurate to usage - - this isn't rss because pages are overcounted - - still doesn't work with go code though -- heaptrack - - seems to just work - - ehh, nope diff --git a/posts/wip/basic-software-profiling-part-1-cpu-usage.md b/posts/wip/basic-software-profiling-part-1-cpu-usage.md @@ -0,0 +1,304 @@ +# Basic Software Profiling, Part 1: CPU Usage + +There aren't many good resources that explain software profiling in an approachable and applicable way. I hope these posts can help readers understand basic software profiling techniques without getting too in the weeds, as I believe getting too into the nuances of performance tends to cause people to dismiss it as something too specialized to try reasoning about. + +## Tools + +[Perf](https://en.wikipedia.org/wiki/Perf_%28Linux%29) is your friend. Unfortunately, only one of the three most popular operating systems (Linux, OpenBSD, FreeBSD) supports perf, but there are sufficient analogs on FreeBSD, and if you're on OpenBSD good luck. + +You might also want a visualization tool. I'll be showing [flamegraph](https://github.com/brendangregg/FlameGraph). Normally I just use perf because [it is very powerful](https://www.brendangregg.com/perf.html), but having pleasing visuals is useful for demonstrations (newer versions of `perf` can also generate flamegraphs directly, but they aren't as aesthetic). + +## Reading a flamegraph + +Let's start with something easy, how do you read a flamegraph? Take a look at the following flamegraph and, without my help, try to understand what's being shown: + +<object data="https://blog.laack.co/images/ex1-fg.svg" type="image/svg+xml" width="100%"></object> + +The amount of time spent with the `main` function on the stack is represented by the width of its bar. + +Notice how there are multiple bars that say `square`. This is because we execute `square` at different stack depths, and the width of each bar is dictated by the amount of time we spent with `square` on the call stack at a given stack depth. + +Given how the widths are calculated, we can deduce the top-down width of a bar is how much time the program spent executing a specific function. In the case of `squareHelper` and `square`, we see we spent more time executing `squareHelper` than `square`, evidenced by the fact that from a top-down view, `squareHelper` is wider. + +The astute among you might've noticed that `square` and `squareHelper` appear to sometimes be executed outside of the main loop. This is due to how stack depth is calculated, and that's a bit more technical than I'll be able to discuss here. + +## Perf + +I've been a little loose with my words thus far in describing flamegraphs. The command I've been using with perf to generate the data for flamegraphs isn't tracking the amount of time spent with a function on the stack at a given depth, we are instead tracking the number of on-CPU samples taken with the function on the top of the call stack. This distinction is important because things like blocking I/O will not be reflected in our timings. Additionally, since perf is interrupt based, it may miss some data, but it gives a good enough approximation of CPU utilization. + +``` +perf record -g ./ex1 +``` + +This is the command I ran to generate the data for the flamegraph. The `record` command is used to record events that will be written to the `perf.data` file. By default, `perf record` will sample at 1000Hz. The final option, `-g`, is used to specify we are interested in having the call stack included in our data. + +If you want to generate a flamegraph right away, you can run the following command: + +``` +perf script report flamegraph +``` + +This isn't how the flamegraph above was generated because I prefer Brendan's FlameGraph program, but both are fairly similar, and in a pinch, `perf script report flamegraph` will work. A command I use more often to view performance is: + +``` +perf report -g +``` + +``` ++ 100.00% 0.00% ex1 ex1 [.] _start ++ 100.00% 0.00% ex1 libc.so.6 [.] __libc_start_main ++ 100.00% 0.00% ex1 libc.so.6 [.] call_init (inlined) ++ 100.00% 0.00% ex1 libc.so.6 [.] 0x00007f6302a27781 ++ 99.79% 39.46% ex1 ex1 [.] main ++ 34.97% 19.94% ex1 ex1 [.] squareHelper(unsigned int) ++ 29.99% 19.90% ex1 ex1 [.] square(unsigned int) ++ 21.61% 20.69% ex1 ex1 [.] factorial(unsigned int) +... +``` + +or if I'm curious to see function calling information: + +``` +perf report -g --stdio +``` + +``` +... +|--88.87%--main +| | +| |--19.84%--squareHelper(unsigned int) +| | | +| | --4.99%--square(unsigned int) +| | +| |--19.55%--factorial(unsigned int) +| | +| --10.07%--square(unsigned int) +| +|--5.02%--squareHelper(unsigned int) +| +|--4.98%--square(unsigned int) +| +--1.13%--factorial(unsigned int) +... +``` + +In many cases, I find the `--stdio` command a bit difficult to read because the report can get exceptionally wide for any non-trivial program (there are additional CLI options that can help with this), and such navigation in the terminal is difficult. + +The final thing I wanted to mention is if you just want high level information about your program's performance, this is a useful command: + +``` +perf stat ./ex1 +``` + +``` + Performance counter stats for './ex1': + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 132 page-faults:u # 4.1 faults/sec page_faults_per_second + 32,436.48 msec task-clock:u # nan CPUs CPUs_utilized + 356,775 branch-misses:u # 0.0 % branch_miss_rate (88.89%) + 63,706,083,988 branches:u # 1964.0 M/sec branch_frequency (88.89%) + 134,126,037,336 cpu-cycles:u # 4.1 GHz cycles_frequency (88.89%) + 300,951,617,557 instructions:u # 2.2 instructions insn_per_cycle (88.89%) + TopdownL1 # 4.4 % tma_backend_bound + # 61.4 % tma_bad_speculation (88.89%) + # 0.0 % tma_frontend_bound (77.78%) + # 34.2 % tma_retiring (88.89%) + + 32.440411262 seconds time elapsed + + 32.234190000 seconds user + 0.002939000 seconds sys +``` + +This is the command I run most frequently when validating optimizations where the optimization is targeting a portion of the codebase with an outsized footprint. If the program is more uniformly expensive, `perf stat` is likely less useful than a full report / flamegraph. + +## What to optimize + +Start with the functions that are costing the most CPU time. Often a very small number of functions take up the majority of the computation, and these are the ones worth optimizing. As it relates to optimization in this context, I don't expect most people to be hand coding assembly, and if you are, you already know all of this anyways. This is for the people just building normal software, consider what's costly and ask yourself two questions: + +1. Would it be possible to call this function less often +2. Would it be possible to make each call of this function perform less work + +Work is key for most optimization; cache friendliness is important, but what I really want from software I use is for it to not leave tons of performance on the table by using bad algorithms, performing unexpected / unnecessary copies, or calling functions (like draw functions) when they don't have to. + +## Amfora + +Something useful to understand when profiling is the ideal case. Without a conception of how long (roughly) reading a file should take, transferring data, or drawing text, it's hard to understand if performance is to be expected or abnormal. This is very contextual, so I can't answer every question that's relevant for this, but something I've found useful is comparing what I have with something that's similar in ways I'd anticipate that result in similar performance to see where each implementation is spending a disproportionate amount of cycles. + +To this end, when I was working on my Gemini protocol browser I wanted to compare it against a well known browser. Amfora states in the readme that it "aims to be the best looking Gemini client with the most features", and while I absotlutely detest the idea that more features means slower in all cases, they do have some features that make it slower*. Specifically, they have syntax highlighting and per character coloring, neither of which my browser has, instead opting for a simpler line based coloring approach which I believe still results in nice looking gemtext because it's all line based at the end of the day. + +(* They could've done coloring as a second pass perhaps to improve perceived performance, but I'd imagine that'd be more complex, and it would increase the time to having the finalized text displayed) + +I decided the first benchmark I was going to perform was a comparison between their performances when opening large files on my filesystem. This was quickly stopped when I realized amfora has a max file size limit of 2097152 bytes or ~2MB. That's curious, but alright then. Let's just make a file that's bigger than 1MB. + +This is a first pass at a direct comparison so I'm not going to make it the max size, and I'm not going to use a representative text, just a bunch of numbers. + +```python +with open("lf.txt", "w") as f: + for i in range(0,200000): + f.write(str(i) + "\n") +``` + +That should be good enough, the resulting file is ~1.3MB in size. + +I then ran following command: + +``` +perf stat amfora lf.txt + +Performance counter stats for 'amfora lf.txt': + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 2,742 page-faults:u # 9306.7 faults/sec page_faults_per_second + 294.63 msec task-clock:u # nan CPUs CPUs_utilized + 1,052,499 branch-misses:u # 0.2 % branch_miss_rate (90.02%) + 575,712,764 branches:u # 1954.1 M/sec branch_frequency (89.14%) + 955,922,330 cpu-cycles:u # 3.2 GHz cycles_frequency (87.42%) + 2,669,651,845 instructions:u # 2.8 instructions insn_per_cycle (88.36%) + TopdownL1 # 6.7 % tma_backend_bound + # 24.9 % tma_bad_speculation (90.11%) + # 16.4 % tma_frontend_bound (79.92%) + # 52.0 % tma_retiring (90.37%) + + 0.473990805 seconds time elapsed + + 0.272938000 seconds user + 0.021266000 seconds sys + +``` + +This is quite unscientific because I simply Ctrl-C'd out once the first characters had rendered. Here's the same for foreseen: + +``` +perf stat foreseen lf.txt + + Performance counter stats for 'foreseen lf.txt': + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 8,936 page-faults:u # 104842.2 faults/sec page_faults_per_second + 85.23 msec task-clock:u # nan CPUs CPUs_utilized + 209,148 branch-misses:u # 0.1 % branch_miss_rate (88.30%) + 176,970,330 branches:u # 2076.3 M/sec branch_frequency (88.29%) + 248,919,966 cpu-cycles:u # 2.9 GHz cycles_frequency (88.29%) + 736,194,375 instructions:u # 3.0 instructions insn_per_cycle (88.99%) + TopdownL1 # 3.9 % tma_backend_bound + # 29.7 % tma_bad_speculation (89.50%) + # 21.2 % tma_frontend_bound (77.84%) + # 45.2 % tma_retiring (88.33%) + + 0.354029324 seconds time elapsed + + 0.066861000 seconds user + 0.021186000 seconds sys +``` + +Of these metrics, the most comparable one is CPU cycles because they aren't spinning during the time it took me to react to the text having been rendered, but even so, this isn't a very good benchmark, and it's not something I'd post about. + +Since Amfora can highlight code, let's see how the performance comparse if we just add our python code block to the top of that file, and rename it to lf.gmi: + +``` +perf stat amfora lf.gmi + + Performance counter stats for 'amfora lf.gmi': + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 900,174 page-faults:u # 12090.4 faults/sec page_faults_per_second + 74,453.35 msec task-clock:u # nan CPUs CPUs_utilized + 229,042,926 branch-misses:u # 0.4 % branch_miss_rate (88.94%) + 62,713,218,442 branches:u # 842.3 M/sec branch_frequency (88.85%) + 153,193,058,619 cpu-cycles:u # 2.1 GHz cycles_frequency (88.97%) + 306,159,421,078 instructions:u # 2.0 instructions insn_per_cycle (88.90%) + TopdownL1 # 0.6 % tma_backend_bound + # 97.8 % tma_bad_speculation (88.83%) + # -0.1 % tma_frontend_bound (77.86%) + # 1.7 % tma_retiring (88.91%) + + 28.983517177 seconds time elapsed + + 63.894262000 seconds user + 8.207151000 seconds sys +``` + +Woah, that's a lot slower. With foreseen there shouldn't be any difference because each line is treated ~ the same, so something's up here. Let's look at a flamegraph for this. + +<object data="https://blog.laack.co/images/amfora-before.svg" type="image/svg+xml" width="100%"></object> + + +So 68.34% samples occurred while executing the GC, that's a bit surprising, even given how awful garbage collectors are. We also see that 25.47% of the time, most of the remaining time, is spent in the RenderGemini function. Of this, most of it is spent on concatstring3, a function under the hood that's used to concatenate strings. + +Here's where that'd be used in the function: + +``` +rendered += fmt.Sprintf("[%s]", config.GetColorString("preformatted_text")) + + buf + fmt.Sprintf("[%s:%s:-]\r\n", config.GetColorString("regular_text"), config.GetColorString("bg")) + +... + +rendered += buf + "\r\n" + +... + +rendered += ren + +... + +buf += strings.TrimSuffix(lines[i], "\r") + "\r\n" +``` + +Well, there's our problem; each of these seemingly innocuous appends is actually very costly. Unlike sensible OO / procedural programming languages, Go strings are immutable so each of these operations will create an entirely new string each time, and since we accumulate into `buf` until reaching a preformatted text switch line ("```" lines), the file we were trying to open has to re-create the full string 200,000 times, since we only have the tail 200,000 lines in the file don't have a format switcher. + + +This is relatively trivial to solve by using a strings.Builder which doesn't have this issue, and that's [what I did](https://github.com/makew0rld/amfora/pull/370/changes)*. After this change, we can perform our profiling again to find: + +(NOTE: The profiling I did to find this differed slightly from what's shown here, hence the difference in numbers between what we see now, and what's seen in the PR, but they're similar enough) + +``` +perf stat amfora lf.gmi + + Performance counter stats for 'amfora lf.gmi': + + 0 context-switches:u # 0.0 cs/sec cs_per_second + 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second + 6,039 page-faults:u # 4871.9 faults/sec page_faults_per_second + 1,239.55 msec task-clock:u # nan CPUs CPUs_utilized + 3,631,996 branch-misses:u # 0.1 % branch_miss_rate (89.02%) + 3,017,891,055 branches:u # 2434.7 M/sec branch_frequency (88.96%) + 4,654,531,574 cpu-cycles:u # 3.8 GHz cycles_frequency (88.93%) + 14,168,541,807 instructions:u # 3.1 instructions insn_per_cycle (88.81%) + TopdownL1 # 2.2 % tma_backend_bound + # 36.9 % tma_bad_speculation (88.80%) + # 18.5 % tma_frontend_bound (77.83%) + # 42.5 % tma_retiring (88.90%) + + 1.185772969 seconds time elapsed + + 1.193871000 seconds user + 0.039062000 seconds sys +``` + +Much better, that's now using 32x less cycles, and is far faster than before. + +<object data="https://blog.laack.co/images/amfora-after.svg" type="image/svg+xml" width="100%"></object> + +Looking again at the flamegraph, we see the RenderGemini function is now mostly performing word wrapping, and the GC is only utilizing the CPU during 16.48% of our samples, much better. + +We can go deeper into this if we'd like, but there are now 3 ~equally costly groupings, and as performance becomes more diffuse, optimizations will generally have a smaller amount of impact on perf, so we can leave this where it is. + +## Refutations + +I think everything above paints a picture that you don't have to put in that much effort to, in many cases, make things a lot better, and you don't have to be that well versed in optimization either. + +I often hear arguments about how we should just let other people make software and we'll just use it and be happy because they're smarter / better than us at it, this is often the case with libraries, and I so vehemently disagree with this idea. Amfora is a piece of software with 1.4K Github stars, that's existed for > 6 years with 54 contributors; it's not tiny, and yet a glaring issue took this long to find and solve. + +While I do think there is blame in this situation, I don't think there should be any shame in writing bad software, but it's all of our jobs to make our software a little less bad over time, hopefully you can do the same, and help others with that too. + +## What's Next + +Consider learning memory profiling next. I didn't directly discuss the topic because 1) it's more complex and 2) memory related performance issues often manifest, like we saw in the go example, as CPU performance issues too. I also didn't discuss anything related to instrumented profiling; everything I've shown with perf can be done without changing any code. When you can change the code, you have the ability to get more granular than just getting metrics on the basis of functions. Despite the upsides of instrumented profiling, I rarely do it because it often takes more time. The main context where I do it is to get shareable information with others, in a working context, and for intra-function profiling. + +Memory stuff is also more complex across languages, where they do weird stuff like go not using malloc. diff --git a/scripts/convert_wip.sh b/scripts/convert_wip.sh @@ -0,0 +1,5 @@ +for FILE in posts/wip/*.md; do + BASENAME="$(basename "$FILE" .md)" + pandoc "$FILE" -o "posts/site_wip/$BASENAME.html" -s --css=style.css --wrap=none --syntax-highlighting=scripts/my_style.theme +done +