blog

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

commit 6c28d638d8886e07e7911dd946b31155ca0479f2
parent c3d27d4f253dee40275fc522286013c90288cab6
Author: Andrew Laack <andrew@laack.co>
Date:   Thu, 15 Oct 2026 17:01:50 -0500

Working on various things

Diffstat:
Mperf/gemini-protocol/amfora-after.svg | 402-------------------------------------------------------------------------------
Mperf/gemini-protocol/amfora-before.svg | 402-------------------------------------------------------------------------------
Mperf/gemini-protocol/ex1.svg | 402-------------------------------------------------------------------------------
Aperf/otr/times.txt | 41+++++++++++++++++++++++++++++++++++++++++
Mposts/gemini/feed.xml | 2+-
Mposts/gemini/index.gmi | 1+
Mposts/site_wip/basic-software-profiling-cpu-usage.html | 20++++++++++----------
Mposts/site_wip/constrained-software-revolution.html | 2+-
Aposts/site_wip/fault-injection.html | 38++++++++++++++++++++++++++++++++++++++
Mposts/site_wip/my-favorite-piece-of-software.html | 2+-
Aposts/site_wip/posix-shell-jobs.html | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aposts/site_wip/search-is-the-problem.html | 46++++++++++++++++++++++++++++++++++++++++++++++
Mposts/wip/basic-software-profiling-cpu-usage.md | 21++++++++++-----------
Mposts/wip/constrained-software-revolution.md | 2+-
Aposts/wip/fault-injection.md | 8++++++++
Mposts/wip/my-favorite-piece-of-software.md | 2+-
Aposts/wip/posix-shell-jobs.md | 33+++++++++++++++++++++++++++++++++
Aposts/wip/search-is-the-problem.md | 41+++++++++++++++++++++++++++++++++++++++++
18 files changed, 287 insertions(+), 1232 deletions(-)

diff --git a/perf/gemini-protocol/amfora-after.svg b/perf/gemini-protocol/amfora-after.svg @@ -20,408 +20,6 @@ .hide { display:none; } .parent { opacity:0.5; } </style> -<script type="text/ecmascript"> -<![CDATA[ - "use strict"; - var details, searchbtn, unzoombtn, matchedtxt, svg, searching, currentSearchTerm, ignorecase, ignorecaseBtn; - function init(evt) { - details = document.getElementById("details").firstChild; - searchbtn = document.getElementById("search"); - ignorecaseBtn = document.getElementById("ignorecase"); - unzoombtn = document.getElementById("unzoom"); - matchedtxt = document.getElementById("matched"); - svg = document.getElementsByTagName("svg")[0]; - searching = 0; - currentSearchTerm = null; - - // use GET parameters to restore a flamegraphs state. - var params = get_params(); - if (params.x && params.y) - zoom(find_group(document.querySelector('[x="' + params.x + '"][y="' + params.y + '"]'))); - if (params.s) search(params.s); - } - - // event listeners - window.addEventListener("click", function(e) { - var target = find_group(e.target); - if (target) { - if (target.nodeName == "a") { - if (e.ctrlKey === false) return; - e.preventDefault(); - } - if (target.classList.contains("parent")) unzoom(true); - zoom(target); - if (!document.querySelector('.parent')) { - // we have basically done a clearzoom so clear the url - var params = get_params(); - if (params.x) delete params.x; - if (params.y) delete params.y; - history.replaceState(null, null, parse_params(params)); - unzoombtn.classList.add("hide"); - return; - } - - // set parameters for zoom state - var el = target.querySelector("rect"); - if (el && el.attributes && el.attributes.y && el.attributes._orig_x) { - var params = get_params() - params.x = el.attributes._orig_x.value; - params.y = el.attributes.y.value; - history.replaceState(null, null, parse_params(params)); - } - } - else if (e.target.id == "unzoom") clearzoom(); - else if (e.target.id == "search") search_prompt(); - else if (e.target.id == "ignorecase") toggle_ignorecase(); - }, false) - - // mouse-over for info - // show - window.addEventListener("mouseover", function(e) { - var target = find_group(e.target); - if (target) details.nodeValue = "Function: " + g_to_text(target); - }, false) - - // clear - window.addEventListener("mouseout", function(e) { - var target = find_group(e.target); - if (target) details.nodeValue = ' '; - }, false) - - // ctrl-F for search - // ctrl-I to toggle case-sensitive search - window.addEventListener("keydown",function (e) { - if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) { - e.preventDefault(); - search_prompt(); - } - else if (e.ctrlKey && e.keyCode === 73) { - e.preventDefault(); - toggle_ignorecase(); - } - }, false) - - // functions - function get_params() { - var params = {}; - var paramsarr = window.location.search.substr(1).split('&'); - for (var i = 0; i < paramsarr.length; ++i) { - var tmp = paramsarr[i].split("="); - if (!tmp[0] || !tmp[1]) continue; - params[tmp[0]] = decodeURIComponent(tmp[1]); - } - return params; - } - function parse_params(params) { - var uri = "?"; - for (var key in params) { - uri += key + '=' + encodeURIComponent(params[key]) + '&'; - } - if (uri.slice(-1) == "&") - uri = uri.substring(0, uri.length - 1); - if (uri == '?') - uri = window.location.href.split('?')[0]; - return uri; - } - function find_child(node, selector) { - var children = node.querySelectorAll(selector); - if (children.length) return children[0]; - } - function find_group(node) { - var parent = node.parentElement; - if (!parent) return; - if (parent.id == "frames") return node; - return find_group(parent); - } - function orig_save(e, attr, val) { - if (e.attributes["_orig_" + attr] != undefined) return; - if (e.attributes[attr] == undefined) return; - if (val == undefined) val = e.attributes[attr].value; - e.setAttribute("_orig_" + attr, val); - } - function orig_load(e, attr) { - if (e.attributes["_orig_"+attr] == undefined) return; - e.attributes[attr].value = e.attributes["_orig_" + attr].value; - e.removeAttribute("_orig_"+attr); - } - function g_to_text(e) { - var text = find_child(e, "title").firstChild.nodeValue; - return (text) - } - function g_to_func(e) { - var func = g_to_text(e); - // if there's any manipulation we want to do to the function - // name before it's searched, do it here before returning. - return (func); - } - function update_text(e) { - var r = find_child(e, "rect"); - var t = find_child(e, "text"); - var w = parseFloat(r.attributes.width.value) -3; - var txt = find_child(e, "title").textContent.replace(/\([^(]*\)$/,""); - t.attributes.x.value = parseFloat(r.attributes.x.value) + 3; - - // Smaller than this size won't fit anything - if (w < 2 * 12 * 0.59) { - t.textContent = ""; - return; - } - - t.textContent = txt; - var sl = t.getSubStringLength(0, txt.length); - // check if only whitespace or if we can fit the entire string into width w - if (/^ *$/.test(txt) || sl < w) - return; - - // this isn't perfect, but gives a good starting point - // and avoids calling getSubStringLength too often - var start = Math.floor((w/sl) * txt.length); - for (var x = start; x > 0; x = x-2) { - if (t.getSubStringLength(0, x + 2) <= w) { - t.textContent = txt.substring(0, x) + ".."; - return; - } - } - t.textContent = ""; - } - - // zoom - function zoom_reset(e) { - if (e.attributes != undefined) { - orig_load(e, "x"); - orig_load(e, "width"); - } - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_reset(c[i]); - } - } - function zoom_child(e, x, ratio) { - if (e.attributes != undefined) { - if (e.attributes.x != undefined) { - orig_save(e, "x"); - e.attributes.x.value = (parseFloat(e.attributes.x.value) - x - 10) * ratio + 10; - if (e.tagName == "text") - e.attributes.x.value = find_child(e.parentNode, "rect[x]").attributes.x.value + 3; - } - if (e.attributes.width != undefined) { - orig_save(e, "width"); - e.attributes.width.value = parseFloat(e.attributes.width.value) * ratio; - } - } - - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_child(c[i], x - 10, ratio); - } - } - function zoom_parent(e) { - if (e.attributes) { - if (e.attributes.x != undefined) { - orig_save(e, "x"); - e.attributes.x.value = 10; - } - if (e.attributes.width != undefined) { - orig_save(e, "width"); - e.attributes.width.value = parseInt(svg.width.baseVal.value) - (10 * 2); - } - } - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_parent(c[i]); - } - } - function zoom(node) { - var attr = find_child(node, "rect").attributes; - var width = parseFloat(attr.width.value); - var xmin = parseFloat(attr.x.value); - var xmax = parseFloat(xmin + width); - var ymin = parseFloat(attr.y.value); - var ratio = (svg.width.baseVal.value - 2 * 10) / width; - - // XXX: Workaround for JavaScript float issues (fix me) - var fudge = 0.0001; - - unzoombtn.classList.remove("hide"); - - var el = document.getElementById("frames").children; - for (var i = 0; i < el.length; i++) { - var e = el[i]; - var a = find_child(e, "rect").attributes; - var ex = parseFloat(a.x.value); - var ew = parseFloat(a.width.value); - var upstack; - // Is it an ancestor - if (0 == 0) { - upstack = parseFloat(a.y.value) > ymin; - } else { - upstack = parseFloat(a.y.value) < ymin; - } - if (upstack) { - // Direct ancestor - if (ex <= xmin && (ex+ew+fudge) >= xmax) { - e.classList.add("parent"); - zoom_parent(e); - update_text(e); - } - // not in current path - else - e.classList.add("hide"); - } - // Children maybe - else { - // no common path - if (ex < xmin || ex + fudge >= xmax) { - e.classList.add("hide"); - } - else { - zoom_child(e, xmin, ratio); - update_text(e); - } - } - } - search(); - } - function unzoom(dont_update_text) { - unzoombtn.classList.add("hide"); - var el = document.getElementById("frames").children; - for(var i = 0; i < el.length; i++) { - el[i].classList.remove("parent"); - el[i].classList.remove("hide"); - zoom_reset(el[i]); - if(!dont_update_text) update_text(el[i]); - } - search(); - } - function clearzoom() { - unzoom(); - - // remove zoom state - var params = get_params(); - if (params.x) delete params.x; - if (params.y) delete params.y; - history.replaceState(null, null, parse_params(params)); - } - - // search - function toggle_ignorecase() { - ignorecase = !ignorecase; - if (ignorecase) { - ignorecaseBtn.classList.add("show"); - } else { - ignorecaseBtn.classList.remove("show"); - } - reset_search(); - search(); - } - function reset_search() { - var el = document.querySelectorAll("#frames rect"); - for (var i = 0; i < el.length; i++) { - orig_load(el[i], "fill") - } - var params = get_params(); - delete params.s; - history.replaceState(null, null, parse_params(params)); - } - function search_prompt() { - if (!searching) { - var term = prompt("Enter a search term (regexp " + - "allowed, eg: ^ext4_)" - + (ignorecase ? ", ignoring case" : "") - + "\nPress Ctrl-i to toggle case sensitivity", ""); - if (term != null) search(term); - } else { - reset_search(); - searching = 0; - currentSearchTerm = null; - searchbtn.classList.remove("show"); - searchbtn.firstChild.nodeValue = "Search" - matchedtxt.classList.add("hide"); - matchedtxt.firstChild.nodeValue = "" - } - } - function search(term) { - if (term) currentSearchTerm = term; - if (currentSearchTerm === null) return; - - var re = new RegExp(currentSearchTerm, ignorecase ? 'i' : ''); - var el = document.getElementById("frames").children; - var matches = new Object(); - var maxwidth = 0; - for (var i = 0; i < el.length; i++) { - var e = el[i]; - var func = g_to_func(e); - var rect = find_child(e, "rect"); - if (func == null || rect == null) - continue; - - // Save max width. Only works as we have a root frame - var w = parseFloat(rect.attributes.width.value); - if (w > maxwidth) - maxwidth = w; - - if (func.match(re)) { - // highlight - var x = parseFloat(rect.attributes.x.value); - orig_save(rect, "fill"); - rect.attributes.fill.value = "rgb(230,0,230)"; - - // remember matches - if (matches[x] == undefined) { - matches[x] = w; - } else { - if (w > matches[x]) { - // overwrite with parent - matches[x] = w; - } - } - searching = 1; - } - } - if (!searching) - return; - var params = get_params(); - params.s = currentSearchTerm; - history.replaceState(null, null, parse_params(params)); - - searchbtn.classList.add("show"); - searchbtn.firstChild.nodeValue = "Reset Search"; - - // calculate percent matched, excluding vertical overlap - var count = 0; - var lastx = -1; - var lastw = 0; - var keys = Array(); - for (k in matches) { - if (matches.hasOwnProperty(k)) - keys.push(k); - } - // sort the matched frames by their x location - // ascending, then width descending - keys.sort(function(a, b){ - return a - b; - }); - // Step through frames saving only the biggest bottom-up frames - // thanks to the sort order. This relies on the tree property - // where children are always smaller than their parents. - var fudge = 0.0001; // JavaScript floating point - for (var k in keys) { - var x = parseFloat(keys[k]); - var w = matches[keys[k]]; - if (x >= lastx + lastw - fudge) { - count += w; - lastx = x; - lastw = w; - } - } - // display matched percent - matchedtxt.classList.remove("hide"); - var pct = 100 * count / maxwidth; - if (pct != 100) pct = pct.toFixed(1) - matchedtxt.firstChild.nodeValue = "Matched: " + pct + "%"; - } -]]> -</script> <rect x="0.0" y="0" width="1200.0" height="774.0" fill="url(#background)" /> <text id="title" x="600.00" y="24" >Flame Graph</text> <text id="details" x="10.00" y="757" > </text> diff --git a/perf/gemini-protocol/amfora-before.svg b/perf/gemini-protocol/amfora-before.svg @@ -20,408 +20,6 @@ .hide { display:none; } .parent { opacity:0.5; } </style> -<script type="text/ecmascript"> -<![CDATA[ - "use strict"; - var details, searchbtn, unzoombtn, matchedtxt, svg, searching, currentSearchTerm, ignorecase, ignorecaseBtn; - function init(evt) { - details = document.getElementById("details").firstChild; - searchbtn = document.getElementById("search"); - ignorecaseBtn = document.getElementById("ignorecase"); - unzoombtn = document.getElementById("unzoom"); - matchedtxt = document.getElementById("matched"); - svg = document.getElementsByTagName("svg")[0]; - searching = 0; - currentSearchTerm = null; - - // use GET parameters to restore a flamegraphs state. - var params = get_params(); - if (params.x && params.y) - zoom(find_group(document.querySelector('[x="' + params.x + '"][y="' + params.y + '"]'))); - if (params.s) search(params.s); - } - - // event listeners - window.addEventListener("click", function(e) { - var target = find_group(e.target); - if (target) { - if (target.nodeName == "a") { - if (e.ctrlKey === false) return; - e.preventDefault(); - } - if (target.classList.contains("parent")) unzoom(true); - zoom(target); - if (!document.querySelector('.parent')) { - // we have basically done a clearzoom so clear the url - var params = get_params(); - if (params.x) delete params.x; - if (params.y) delete params.y; - history.replaceState(null, null, parse_params(params)); - unzoombtn.classList.add("hide"); - return; - } - - // set parameters for zoom state - var el = target.querySelector("rect"); - if (el && el.attributes && el.attributes.y && el.attributes._orig_x) { - var params = get_params() - params.x = el.attributes._orig_x.value; - params.y = el.attributes.y.value; - history.replaceState(null, null, parse_params(params)); - } - } - else if (e.target.id == "unzoom") clearzoom(); - else if (e.target.id == "search") search_prompt(); - else if (e.target.id == "ignorecase") toggle_ignorecase(); - }, false) - - // mouse-over for info - // show - window.addEventListener("mouseover", function(e) { - var target = find_group(e.target); - if (target) details.nodeValue = "Function: " + g_to_text(target); - }, false) - - // clear - window.addEventListener("mouseout", function(e) { - var target = find_group(e.target); - if (target) details.nodeValue = ' '; - }, false) - - // ctrl-F for search - // ctrl-I to toggle case-sensitive search - window.addEventListener("keydown",function (e) { - if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) { - e.preventDefault(); - search_prompt(); - } - else if (e.ctrlKey && e.keyCode === 73) { - e.preventDefault(); - toggle_ignorecase(); - } - }, false) - - // functions - function get_params() { - var params = {}; - var paramsarr = window.location.search.substr(1).split('&'); - for (var i = 0; i < paramsarr.length; ++i) { - var tmp = paramsarr[i].split("="); - if (!tmp[0] || !tmp[1]) continue; - params[tmp[0]] = decodeURIComponent(tmp[1]); - } - return params; - } - function parse_params(params) { - var uri = "?"; - for (var key in params) { - uri += key + '=' + encodeURIComponent(params[key]) + '&'; - } - if (uri.slice(-1) == "&") - uri = uri.substring(0, uri.length - 1); - if (uri == '?') - uri = window.location.href.split('?')[0]; - return uri; - } - function find_child(node, selector) { - var children = node.querySelectorAll(selector); - if (children.length) return children[0]; - } - function find_group(node) { - var parent = node.parentElement; - if (!parent) return; - if (parent.id == "frames") return node; - return find_group(parent); - } - function orig_save(e, attr, val) { - if (e.attributes["_orig_" + attr] != undefined) return; - if (e.attributes[attr] == undefined) return; - if (val == undefined) val = e.attributes[attr].value; - e.setAttribute("_orig_" + attr, val); - } - function orig_load(e, attr) { - if (e.attributes["_orig_"+attr] == undefined) return; - e.attributes[attr].value = e.attributes["_orig_" + attr].value; - e.removeAttribute("_orig_"+attr); - } - function g_to_text(e) { - var text = find_child(e, "title").firstChild.nodeValue; - return (text) - } - function g_to_func(e) { - var func = g_to_text(e); - // if there's any manipulation we want to do to the function - // name before it's searched, do it here before returning. - return (func); - } - function update_text(e) { - var r = find_child(e, "rect"); - var t = find_child(e, "text"); - var w = parseFloat(r.attributes.width.value) -3; - var txt = find_child(e, "title").textContent.replace(/\([^(]*\)$/,""); - t.attributes.x.value = parseFloat(r.attributes.x.value) + 3; - - // Smaller than this size won't fit anything - if (w < 2 * 12 * 0.59) { - t.textContent = ""; - return; - } - - t.textContent = txt; - var sl = t.getSubStringLength(0, txt.length); - // check if only whitespace or if we can fit the entire string into width w - if (/^ *$/.test(txt) || sl < w) - return; - - // this isn't perfect, but gives a good starting point - // and avoids calling getSubStringLength too often - var start = Math.floor((w/sl) * txt.length); - for (var x = start; x > 0; x = x-2) { - if (t.getSubStringLength(0, x + 2) <= w) { - t.textContent = txt.substring(0, x) + ".."; - return; - } - } - t.textContent = ""; - } - - // zoom - function zoom_reset(e) { - if (e.attributes != undefined) { - orig_load(e, "x"); - orig_load(e, "width"); - } - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_reset(c[i]); - } - } - function zoom_child(e, x, ratio) { - if (e.attributes != undefined) { - if (e.attributes.x != undefined) { - orig_save(e, "x"); - e.attributes.x.value = (parseFloat(e.attributes.x.value) - x - 10) * ratio + 10; - if (e.tagName == "text") - e.attributes.x.value = find_child(e.parentNode, "rect[x]").attributes.x.value + 3; - } - if (e.attributes.width != undefined) { - orig_save(e, "width"); - e.attributes.width.value = parseFloat(e.attributes.width.value) * ratio; - } - } - - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_child(c[i], x - 10, ratio); - } - } - function zoom_parent(e) { - if (e.attributes) { - if (e.attributes.x != undefined) { - orig_save(e, "x"); - e.attributes.x.value = 10; - } - if (e.attributes.width != undefined) { - orig_save(e, "width"); - e.attributes.width.value = parseInt(svg.width.baseVal.value) - (10 * 2); - } - } - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_parent(c[i]); - } - } - function zoom(node) { - var attr = find_child(node, "rect").attributes; - var width = parseFloat(attr.width.value); - var xmin = parseFloat(attr.x.value); - var xmax = parseFloat(xmin + width); - var ymin = parseFloat(attr.y.value); - var ratio = (svg.width.baseVal.value - 2 * 10) / width; - - // XXX: Workaround for JavaScript float issues (fix me) - var fudge = 0.0001; - - unzoombtn.classList.remove("hide"); - - var el = document.getElementById("frames").children; - for (var i = 0; i < el.length; i++) { - var e = el[i]; - var a = find_child(e, "rect").attributes; - var ex = parseFloat(a.x.value); - var ew = parseFloat(a.width.value); - var upstack; - // Is it an ancestor - if (0 == 0) { - upstack = parseFloat(a.y.value) > ymin; - } else { - upstack = parseFloat(a.y.value) < ymin; - } - if (upstack) { - // Direct ancestor - if (ex <= xmin && (ex+ew+fudge) >= xmax) { - e.classList.add("parent"); - zoom_parent(e); - update_text(e); - } - // not in current path - else - e.classList.add("hide"); - } - // Children maybe - else { - // no common path - if (ex < xmin || ex + fudge >= xmax) { - e.classList.add("hide"); - } - else { - zoom_child(e, xmin, ratio); - update_text(e); - } - } - } - search(); - } - function unzoom(dont_update_text) { - unzoombtn.classList.add("hide"); - var el = document.getElementById("frames").children; - for(var i = 0; i < el.length; i++) { - el[i].classList.remove("parent"); - el[i].classList.remove("hide"); - zoom_reset(el[i]); - if(!dont_update_text) update_text(el[i]); - } - search(); - } - function clearzoom() { - unzoom(); - - // remove zoom state - var params = get_params(); - if (params.x) delete params.x; - if (params.y) delete params.y; - history.replaceState(null, null, parse_params(params)); - } - - // search - function toggle_ignorecase() { - ignorecase = !ignorecase; - if (ignorecase) { - ignorecaseBtn.classList.add("show"); - } else { - ignorecaseBtn.classList.remove("show"); - } - reset_search(); - search(); - } - function reset_search() { - var el = document.querySelectorAll("#frames rect"); - for (var i = 0; i < el.length; i++) { - orig_load(el[i], "fill") - } - var params = get_params(); - delete params.s; - history.replaceState(null, null, parse_params(params)); - } - function search_prompt() { - if (!searching) { - var term = prompt("Enter a search term (regexp " + - "allowed, eg: ^ext4_)" - + (ignorecase ? ", ignoring case" : "") - + "\nPress Ctrl-i to toggle case sensitivity", ""); - if (term != null) search(term); - } else { - reset_search(); - searching = 0; - currentSearchTerm = null; - searchbtn.classList.remove("show"); - searchbtn.firstChild.nodeValue = "Search" - matchedtxt.classList.add("hide"); - matchedtxt.firstChild.nodeValue = "" - } - } - function search(term) { - if (term) currentSearchTerm = term; - if (currentSearchTerm === null) return; - - var re = new RegExp(currentSearchTerm, ignorecase ? 'i' : ''); - var el = document.getElementById("frames").children; - var matches = new Object(); - var maxwidth = 0; - for (var i = 0; i < el.length; i++) { - var e = el[i]; - var func = g_to_func(e); - var rect = find_child(e, "rect"); - if (func == null || rect == null) - continue; - - // Save max width. Only works as we have a root frame - var w = parseFloat(rect.attributes.width.value); - if (w > maxwidth) - maxwidth = w; - - if (func.match(re)) { - // highlight - var x = parseFloat(rect.attributes.x.value); - orig_save(rect, "fill"); - rect.attributes.fill.value = "rgb(230,0,230)"; - - // remember matches - if (matches[x] == undefined) { - matches[x] = w; - } else { - if (w > matches[x]) { - // overwrite with parent - matches[x] = w; - } - } - searching = 1; - } - } - if (!searching) - return; - var params = get_params(); - params.s = currentSearchTerm; - history.replaceState(null, null, parse_params(params)); - - searchbtn.classList.add("show"); - searchbtn.firstChild.nodeValue = "Reset Search"; - - // calculate percent matched, excluding vertical overlap - var count = 0; - var lastx = -1; - var lastw = 0; - var keys = Array(); - for (k in matches) { - if (matches.hasOwnProperty(k)) - keys.push(k); - } - // sort the matched frames by their x location - // ascending, then width descending - keys.sort(function(a, b){ - return a - b; - }); - // Step through frames saving only the biggest bottom-up frames - // thanks to the sort order. This relies on the tree property - // where children are always smaller than their parents. - var fudge = 0.0001; // JavaScript floating point - for (var k in keys) { - var x = parseFloat(keys[k]); - var w = matches[keys[k]]; - if (x >= lastx + lastw - fudge) { - count += w; - lastx = x; - lastw = w; - } - } - // display matched percent - matchedtxt.classList.remove("hide"); - var pct = 100 * count / maxwidth; - if (pct != 100) pct = pct.toFixed(1) - matchedtxt.firstChild.nodeValue = "Matched: " + pct + "%"; - } -]]> -</script> <rect x="0.0" y="0" width="1200.0" height="614.0" fill="url(#background)" /> <text id="title" x="600.00" y="24" >Flame Graph</text> <text id="details" x="10.00" y="597" > </text> diff --git a/perf/gemini-protocol/ex1.svg b/perf/gemini-protocol/ex1.svg @@ -20,408 +20,6 @@ .hide { display:none; } .parent { opacity:0.5; } </style> -<script type="text/ecmascript"> -<![CDATA[ - "use strict"; - var details, searchbtn, unzoombtn, matchedtxt, svg, searching, currentSearchTerm, ignorecase, ignorecaseBtn; - function init(evt) { - details = document.getElementById("details").firstChild; - searchbtn = document.getElementById("search"); - ignorecaseBtn = document.getElementById("ignorecase"); - unzoombtn = document.getElementById("unzoom"); - matchedtxt = document.getElementById("matched"); - svg = document.getElementsByTagName("svg")[0]; - searching = 0; - currentSearchTerm = null; - - // use GET parameters to restore a flamegraphs state. - var params = get_params(); - if (params.x && params.y) - zoom(find_group(document.querySelector('[x="' + params.x + '"][y="' + params.y + '"]'))); - if (params.s) search(params.s); - } - - // event listeners - window.addEventListener("click", function(e) { - var target = find_group(e.target); - if (target) { - if (target.nodeName == "a") { - if (e.ctrlKey === false) return; - e.preventDefault(); - } - if (target.classList.contains("parent")) unzoom(true); - zoom(target); - if (!document.querySelector('.parent')) { - // we have basically done a clearzoom so clear the url - var params = get_params(); - if (params.x) delete params.x; - if (params.y) delete params.y; - history.replaceState(null, null, parse_params(params)); - unzoombtn.classList.add("hide"); - return; - } - - // set parameters for zoom state - var el = target.querySelector("rect"); - if (el && el.attributes && el.attributes.y && el.attributes._orig_x) { - var params = get_params() - params.x = el.attributes._orig_x.value; - params.y = el.attributes.y.value; - history.replaceState(null, null, parse_params(params)); - } - } - else if (e.target.id == "unzoom") clearzoom(); - else if (e.target.id == "search") search_prompt(); - else if (e.target.id == "ignorecase") toggle_ignorecase(); - }, false) - - // mouse-over for info - // show - window.addEventListener("mouseover", function(e) { - var target = find_group(e.target); - if (target) details.nodeValue = "Function: " + g_to_text(target); - }, false) - - // clear - window.addEventListener("mouseout", function(e) { - var target = find_group(e.target); - if (target) details.nodeValue = ' '; - }, false) - - // ctrl-F for search - // ctrl-I to toggle case-sensitive search - window.addEventListener("keydown",function (e) { - if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) { - e.preventDefault(); - search_prompt(); - } - else if (e.ctrlKey && e.keyCode === 73) { - e.preventDefault(); - toggle_ignorecase(); - } - }, false) - - // functions - function get_params() { - var params = {}; - var paramsarr = window.location.search.substr(1).split('&'); - for (var i = 0; i < paramsarr.length; ++i) { - var tmp = paramsarr[i].split("="); - if (!tmp[0] || !tmp[1]) continue; - params[tmp[0]] = decodeURIComponent(tmp[1]); - } - return params; - } - function parse_params(params) { - var uri = "?"; - for (var key in params) { - uri += key + '=' + encodeURIComponent(params[key]) + '&'; - } - if (uri.slice(-1) == "&") - uri = uri.substring(0, uri.length - 1); - if (uri == '?') - uri = window.location.href.split('?')[0]; - return uri; - } - function find_child(node, selector) { - var children = node.querySelectorAll(selector); - if (children.length) return children[0]; - } - function find_group(node) { - var parent = node.parentElement; - if (!parent) return; - if (parent.id == "frames") return node; - return find_group(parent); - } - function orig_save(e, attr, val) { - if (e.attributes["_orig_" + attr] != undefined) return; - if (e.attributes[attr] == undefined) return; - if (val == undefined) val = e.attributes[attr].value; - e.setAttribute("_orig_" + attr, val); - } - function orig_load(e, attr) { - if (e.attributes["_orig_"+attr] == undefined) return; - e.attributes[attr].value = e.attributes["_orig_" + attr].value; - e.removeAttribute("_orig_"+attr); - } - function g_to_text(e) { - var text = find_child(e, "title").firstChild.nodeValue; - return (text) - } - function g_to_func(e) { - var func = g_to_text(e); - // if there's any manipulation we want to do to the function - // name before it's searched, do it here before returning. - return (func); - } - function update_text(e) { - var r = find_child(e, "rect"); - var t = find_child(e, "text"); - var w = parseFloat(r.attributes.width.value) -3; - var txt = find_child(e, "title").textContent.replace(/\([^(]*\)$/,""); - t.attributes.x.value = parseFloat(r.attributes.x.value) + 3; - - // Smaller than this size won't fit anything - if (w < 2 * 12 * 0.59) { - t.textContent = ""; - return; - } - - t.textContent = txt; - var sl = t.getSubStringLength(0, txt.length); - // check if only whitespace or if we can fit the entire string into width w - if (/^ *$/.test(txt) || sl < w) - return; - - // this isn't perfect, but gives a good starting point - // and avoids calling getSubStringLength too often - var start = Math.floor((w/sl) * txt.length); - for (var x = start; x > 0; x = x-2) { - if (t.getSubStringLength(0, x + 2) <= w) { - t.textContent = txt.substring(0, x) + ".."; - return; - } - } - t.textContent = ""; - } - - // zoom - function zoom_reset(e) { - if (e.attributes != undefined) { - orig_load(e, "x"); - orig_load(e, "width"); - } - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_reset(c[i]); - } - } - function zoom_child(e, x, ratio) { - if (e.attributes != undefined) { - if (e.attributes.x != undefined) { - orig_save(e, "x"); - e.attributes.x.value = (parseFloat(e.attributes.x.value) - x - 10) * ratio + 10; - if (e.tagName == "text") - e.attributes.x.value = find_child(e.parentNode, "rect[x]").attributes.x.value + 3; - } - if (e.attributes.width != undefined) { - orig_save(e, "width"); - e.attributes.width.value = parseFloat(e.attributes.width.value) * ratio; - } - } - - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_child(c[i], x - 10, ratio); - } - } - function zoom_parent(e) { - if (e.attributes) { - if (e.attributes.x != undefined) { - orig_save(e, "x"); - e.attributes.x.value = 10; - } - if (e.attributes.width != undefined) { - orig_save(e, "width"); - e.attributes.width.value = parseInt(svg.width.baseVal.value) - (10 * 2); - } - } - if (e.childNodes == undefined) return; - for (var i = 0, c = e.childNodes; i < c.length; i++) { - zoom_parent(c[i]); - } - } - function zoom(node) { - var attr = find_child(node, "rect").attributes; - var width = parseFloat(attr.width.value); - var xmin = parseFloat(attr.x.value); - var xmax = parseFloat(xmin + width); - var ymin = parseFloat(attr.y.value); - var ratio = (svg.width.baseVal.value - 2 * 10) / width; - - // XXX: Workaround for JavaScript float issues (fix me) - var fudge = 0.0001; - - unzoombtn.classList.remove("hide"); - - var el = document.getElementById("frames").children; - for (var i = 0; i < el.length; i++) { - var e = el[i]; - var a = find_child(e, "rect").attributes; - var ex = parseFloat(a.x.value); - var ew = parseFloat(a.width.value); - var upstack; - // Is it an ancestor - if (0 == 0) { - upstack = parseFloat(a.y.value) > ymin; - } else { - upstack = parseFloat(a.y.value) < ymin; - } - if (upstack) { - // Direct ancestor - if (ex <= xmin && (ex+ew+fudge) >= xmax) { - e.classList.add("parent"); - zoom_parent(e); - update_text(e); - } - // not in current path - else - e.classList.add("hide"); - } - // Children maybe - else { - // no common path - if (ex < xmin || ex + fudge >= xmax) { - e.classList.add("hide"); - } - else { - zoom_child(e, xmin, ratio); - update_text(e); - } - } - } - search(); - } - function unzoom(dont_update_text) { - unzoombtn.classList.add("hide"); - var el = document.getElementById("frames").children; - for(var i = 0; i < el.length; i++) { - el[i].classList.remove("parent"); - el[i].classList.remove("hide"); - zoom_reset(el[i]); - if(!dont_update_text) update_text(el[i]); - } - search(); - } - function clearzoom() { - unzoom(); - - // remove zoom state - var params = get_params(); - if (params.x) delete params.x; - if (params.y) delete params.y; - history.replaceState(null, null, parse_params(params)); - } - - // search - function toggle_ignorecase() { - ignorecase = !ignorecase; - if (ignorecase) { - ignorecaseBtn.classList.add("show"); - } else { - ignorecaseBtn.classList.remove("show"); - } - reset_search(); - search(); - } - function reset_search() { - var el = document.querySelectorAll("#frames rect"); - for (var i = 0; i < el.length; i++) { - orig_load(el[i], "fill") - } - var params = get_params(); - delete params.s; - history.replaceState(null, null, parse_params(params)); - } - function search_prompt() { - if (!searching) { - var term = prompt("Enter a search term (regexp " + - "allowed, eg: ^ext4_)" - + (ignorecase ? ", ignoring case" : "") - + "\nPress Ctrl-i to toggle case sensitivity", ""); - if (term != null) search(term); - } else { - reset_search(); - searching = 0; - currentSearchTerm = null; - searchbtn.classList.remove("show"); - searchbtn.firstChild.nodeValue = "Search" - matchedtxt.classList.add("hide"); - matchedtxt.firstChild.nodeValue = "" - } - } - function search(term) { - if (term) currentSearchTerm = term; - if (currentSearchTerm === null) return; - - var re = new RegExp(currentSearchTerm, ignorecase ? 'i' : ''); - var el = document.getElementById("frames").children; - var matches = new Object(); - var maxwidth = 0; - for (var i = 0; i < el.length; i++) { - var e = el[i]; - var func = g_to_func(e); - var rect = find_child(e, "rect"); - if (func == null || rect == null) - continue; - - // Save max width. Only works as we have a root frame - var w = parseFloat(rect.attributes.width.value); - if (w > maxwidth) - maxwidth = w; - - if (func.match(re)) { - // highlight - var x = parseFloat(rect.attributes.x.value); - orig_save(rect, "fill"); - rect.attributes.fill.value = "rgb(230,0,230)"; - - // remember matches - if (matches[x] == undefined) { - matches[x] = w; - } else { - if (w > matches[x]) { - // overwrite with parent - matches[x] = w; - } - } - searching = 1; - } - } - if (!searching) - return; - var params = get_params(); - params.s = currentSearchTerm; - history.replaceState(null, null, parse_params(params)); - - searchbtn.classList.add("show"); - searchbtn.firstChild.nodeValue = "Reset Search"; - - // calculate percent matched, excluding vertical overlap - var count = 0; - var lastx = -1; - var lastw = 0; - var keys = Array(); - for (k in matches) { - if (matches.hasOwnProperty(k)) - keys.push(k); - } - // sort the matched frames by their x location - // ascending, then width descending - keys.sort(function(a, b){ - return a - b; - }); - // Step through frames saving only the biggest bottom-up frames - // thanks to the sort order. This relies on the tree property - // where children are always smaller than their parents. - var fudge = 0.0001; // JavaScript floating point - for (var k in keys) { - var x = parseFloat(keys[k]); - var w = matches[keys[k]]; - if (x >= lastx + lastw - fudge) { - count += w; - lastx = x; - lastw = w; - } - } - // display matched percent - matchedtxt.classList.remove("hide"); - var pct = 100 * count / maxwidth; - if (pct != 100) pct = pct.toFixed(1) - matchedtxt.firstChild.nodeValue = "Matched: " + pct + "%"; - } -]]> -</script> <rect x="0.0" y="0" width="1200.0" height="214.0" fill="url(#background)" /> <text id="title" x="600.00" y="24" >Flame Graph</text> <text id="details" x="10.00" y="197" > </text> diff --git a/perf/otr/times.txt b/perf/otr/times.txt @@ -0,0 +1,41 @@ +Librewolf: + +real 0m2.210s +user 0m2.724s +sys 0m0.560s + +real 0m2.773s +user 0m3.378s +sys 0m0.738s + +real 0m2.626s +user 0m3.033s +sys 0m0.641s + +real 0m2.302s +user 0m2.804s +sys 0m0.632s + +Chromium: + +real 0m1.675s +user 0m1.623s +sys 0m0.500s + +real 0m1.577s +user 0m1.473s +sys 0m0.469s + +Dillo: + +real 0m0.473s +user 0m0.096s +sys 0m0.025s + +real 0m0.450s +user 0m0.092s +sys 0m0.025s + +real 0m0.450s +user 0m0.089s +sys 0m0.031s diff --git a/posts/gemini/feed.xml b/posts/gemini/feed.xml @@ -7,7 +7,7 @@ <language>en-us</language> <managingEditor>andrew@laack.co</managingEditor> <webMaster>andrew@laack.co</webMaster> -<lastBuildDate>Wed, 07 Oct 2026 09:50:43 -0500</lastBuildDate> +<lastBuildDate>Thu, 15 Oct 2026 16:59:50 -0500</lastBuildDate> <atom:link href="gemini://blog.laack.co/feed.xml" rel="self" type="application/rss+xml"/> <item> <title><![CDATA[PyGame vs. Raylib]]></title> diff --git a/posts/gemini/index.gmi b/posts/gemini/index.gmi @@ -8,3 +8,4 @@ => you-dont-need-anything.gmi you-dont-need-anything 2025/10/17 => stop-collecting-user-data.gmi stop-collecting-user-data 2025/10/12 => adnauseum-track-me-not-and-privacy-through-obscurity.gmi adnauseum-track-me-not-and-privacy-through-obscurity 2025/10/4 +=> the-sustainability-of-youtube.gmi the-sustainability-of-youtube 2025/9/28 diff --git a/posts/site_wip/basic-software-profiling-cpu-usage.html b/posts/site_wip/basic-software-profiling-cpu-usage.html @@ -99,11 +99,11 @@ </head> <body> <h1 id="basic-software-profiling-cpu-usage">Basic Software Profiling: CPU Usage</h1> -<p>We waste trillions of CPU cycles every day because software isn’t profiled frequently. I believe this is an educational problem.</p> -<p>This post will explain how you can find the parts of a program hogging the most CPU time. The post will focus on compiled programs, but the core ideas can be applied to interpreted programs.</p> +<p>Tens of millions of human hours are wasted every day because software is slow. The most addressable contributing factor to this state of affairs is education. A specific educational problem is a lack of awareness for how to profile software.</p> +<p>To this end, this post will explain how you can find the parts of programs hogging the most CPU time. This post will focus on compiled programs, but the core ideas may be applied to interpreted programs.</p> <h2 id="tools">Tools</h2> <p><a href="https://en.wikipedia.org/wiki/Perf_%28Linux%29">Perf</a> is a suite of tools for program profiling on Linux. We will mainly use it to collect aggregate performance metrics and call stack information. Analogous tools exist for other Free operating systems, and dedicated tools exist for many interpreted languages to collect call stack information.</p> -<p><a href="https://github.com/brendangregg/FlameGraph">Flamegraph</a> is a suite of tools for generating flamegraphs, a type of graph designed for the visualization of performance data.</p> +<p><a href="https://github.com/brendangregg/FlameGraph">Flamegraph</a> is a suite of tools for generating flamegraphs, a type of graph designed for the visualization of performance data. I use my <a href="https://git.laack.co/flamegraph">fork of flamegraph</a> which doesn’t add j<strong><em>s</em></strong>** to generated SVGs, but apart from this they function identically.</p> <h2 id="reading-a-flamegraph">Reading a Flamegraph</h2> <p>Take a look at the flamegraph below and try to understand the performance characteristics of the program:</p> <object data="/images/ex1-fg.svg" type="image/svg+xml" width="100%"> @@ -217,15 +217,14 @@ Source code for the program that generated this flamegraph <p>Start with functions using lots of CPU time that you wouldn’t expect to. Often a small number of functions do the majority of computation, and these are the ones worth optimizing in the average case. To make these functions run faster, you should consider the following:</p> <ol type="1"> <li>Can we call this function less often</li> -<li>Can each call perform less work via algorithmic improvements</li> +<li>Can each call perform less work</li> </ol> -<p>Both of these questions are about decreasing work, not making the work faster. Making work faster can be complex, and it’s often easier to improve performance by decreasing wasted work and algorithmic improvements.</p> +<p>Both of these questions are about decreasing work, not making the work faster. Making work faster can be complex, so it’s often easier to improve performance by removing wasted work or making algorithmic improvements.</p> <h2 id="case-study">Case Study</h2> <h3 id="amfora">Amfora</h3> -<p><a href="https://github.com/makew0rld/amfora">Amfora</a> is a fancy terminal-based Gemini protocol browser with syntax highlighting. Gemini is a text-based protocol which primarily distributes <a href="https://geminiprotocol.net/docs/gemtext.gmi">gemtext</a> documents. These documents use a similar syntax to markdown, but a bit simpler. I chose this program to profile because software in the Gemini ecosystem is generally quite simple to understand, making it great for educational purposes.</p> -<p>When I start profiling software I often find it useful to use an oracle to understand what’s possible. An oracle in this context is a program that performs comparable tasks with decent performance characteristics.</p> -<p>I chose <a href="https://git.laack.co/foreseen/">Foreseen</a>, a Gemini protocol browser I developed, as the oracle as it has adequate performance, and performs a sensible subset of the tasks performed by Amfora.</p> -<p>I normally start by searching for worst case performance scenarios. Worst cases are often an amplification of an average case, so by improving worst case performance you can often improve average case performance.</p> +<p><a href="https://github.com/makew0rld/amfora">Amfora</a> is a fancy terminal-based Gemini protocol browser with syntax highlighting. Gemini is a text-based protocol which primarily distributes <a href="https://geminiprotocol.net/docs/gemtext.gmi">gemtext</a> documents. These documents use a similar syntax to markdown, but its slightly simpler. I chose to profile this program because software in the Gemini ecosystem is often simple to understand, making it great for educational use cases.</p> +<p>When I start profiling software I often find it useful to use an oracle to understand what’s possible. An oracle in this context is a program that performs comparable tasks with decent performance characteristics. I chose <a href="https://git.laack.co/foreseen/">Foreseen</a>, a Gemini protocol browser I developed, as the oracle because it fulfils both criteria.</p> +<p>I like to start by searching for worst case performance scenarios. Worst cases are often an amplification of an average case, so by improving worst case performance you can often improve average case performance.</p> <p>Let’s look for the worst case for the task of rendering a textual document. We’ll load a large text file from disk using both browsers, killing the program once the first lines of text are drawn. Since neither browser supports text streaming, they will both have to load and parse the document, and then draw some text to the terminal. To generate the document I executed the following Python code:</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> @@ -368,10 +367,11 @@ buf += strings.TrimSuffix(lines[i], &quot;\r&quot;) + &quot;\r\n&quot;</code></p <p>We can go deeper still on this, but there are now 3 ~equally costly groupings, and as performance becomes more diffuse, optimizations will generally have a smaller amount of impact on performance, so we can leave this where it is. Additional optimizations would also require more investment in instrumentation to support profiling, but I believe most people don’t have to go that far since we’ve seen there are often low hanging fruit that are so obviously incorrect that we don’t have to get very scientific to show tangible improvements.</p> <p>(Relevant <a href="https://xkcd.com/2400/">XKCD</a>)</p> <h2 id="whats-next">What’s Next</h2> -<p>This post only discussed on-CPU time profiling. There are two additional metric,s worth profiling I’ll discuss in the future:</p> +<p>This post only discussed on-CPU time profiling for program execution. There are a few additional metrics worth profiling that I’ll discuss in the future:</p> <ol type="1"> <li>Off CPU profiling</li> <li>Memory profiling</li> +<li>Build profiling</li> </ol> </body> </html> diff --git a/posts/site_wip/constrained-software-revolution.html b/posts/site_wip/constrained-software-revolution.html @@ -108,7 +108,7 @@ </blockquote> <p>This is one distinction. There is an underserved niche of software for experienced users, but I don’t believe constrained software should necessarily target this niche. Grandmas should be able to use constrained software; it’s built to be intuitive and simple.</p> <p>Consider Dillo. There are advanced features, facilitated by its plugins system, but the base browser is exceptionally approachable. I’d argue it’s more approachable than Chromium. I won’t claim it would be preferred by many users in its present state, but slight improvements to the usage experience to keep up with modern standards (some stuff with settings and first pass rendering missing css sometimes) would certainly make it as usable or more usable.</p> -<p>The problem right now is most sites people patronize don’t work without J<strong><em>S</em></strong>**. I’ve accepted sites like that aren’t made for me, but it requires widespread disdain to make it known people are sick and tired of this.</p> +<p>The problem right now is most sites people patronize don’t work without j<strong><em>s</em></strong>**. I’ve accepted sites like that aren’t made for me, but it requires widespread disdain to make it known people are sick and tired of this.</p> <hr /> <ul> <li>constrained software diff --git a/posts/site_wip/fault-injection.html b/posts/site_wip/fault-injection.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.11" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>fault-injection</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; + } + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="fault-injection">Fault Injection</h1> +<p>We accept at face value the programs we write will execute how they are written.</p> +<p>What if they don’t?</p> +<p>Fault injection is one such case where the instructions will not be adhered to as expected.</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 @@ -84,7 +84,7 @@ </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 like Lynx quite a bit, but most of the other browsers feel like the lesser of evils. In particular, I don’t think j<strong><em>s</em></strong>** on the web is a good idea, 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> diff --git a/posts/site_wip/posix-shell-jobs.html b/posts/site_wip/posix-shell-jobs.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.11" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>posix-shell-jobs</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; + } + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="posix-shell-jobs">POSIX Shell Jobs</h1> +<p>There are lots of bloated terminal multiplexers and persistence programs, like zellij, tmux, screen, and the new age vibe-coded slop ones. These are all bloat.</p> +<p>It turns out POSIX shell has a lot of this built in.</p> +<h2 id="the-stack">The Stack</h2> +<ul> +<li>st</li> +<li>bash / dash / ash</li> +<li>optional: abduco</li> +</ul> +<p>That’s it. That’s all you need to have the same features as tmux, zellij, ghostty (gross) all in one.</p> +<h2 id="writing-code">Writing Code</h2> +<p>When writing code I used to use a tmux pane with my editor, one with a terminal for execution, and sometimes another with lynx open, as relevant. Since then, I’ve become annoyed by this because I’d much rather have one bash session that does everything instead of dealing with the bloated monstrosity that is tmux.</p> +<p>Instead I do this:</p> +<ul> +<li>write code in vim</li> +<li>C-z it to suspend the program</li> +<li>Run my commands in the newly cleaned bash session</li> +<li>Run ‘fg’ to foreground the suspended session.</li> +</ul> +<pre><code>[andrew@hal wip]$ jobs -l</code></pre> +</body> +</html> diff --git a/posts/site_wip/search-is-the-problem.html b/posts/site_wip/search-is-the-problem.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.11" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>search-is-the-problem</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; + } + </style> + <link rel="stylesheet" href="style.css" /> +</head> +<body> +<h1 id="centralized-search-is-the-problem">(Centralized) Search is the Problem</h1> +<p>Search engines killed the useful, interesting internet. All corners of the www have been infested by companies astroturfing, people with dumbass agendas, and AI slop (no, your slop isn’t different, no you don’t hold it differently, it’s all fucking slop, stop kidding yourself).</p> +<p>Why did this happen? Put simply, I believe this is because of search engines. Search engines attempt to answer queries from a diffuse set of sources, and since this is how most people use the internet, it is a high value target. It has since been solved as a problem. You will never find a blog post of mine in search results, but you’ll find some slop top ten list, even if you search the exact name of my post, which are indexed by search engines mind you. I guarantee my posts are at least better than the average search result quality because I’m not a sell-out, but you won’t find them. I won’t bend the knee to use shady tactics to rank better at the cost of informational quality, and so here I stand.</p> +<p>This leads me to this: what’s the best way to find works from people like me? Distributionally, there’s nothing special about my or anyone else’s blog posts that couldn’t be co-opted by special interests, so the solution is to not use search engines, or at least ones that are calibrated in this way. It’s possible personal search engines could work, ones that index good parts of the web in a selective way, but this isn’t well done yet.</p> +<p>Given this, it seems that discovery is relegated to being your own spider. To be your own spider takes effort, but it’s to the point that the web is so utterly fucking useless that I don’t know what else is left.</p> +<p>Perhaps an alternative could be some sort of self-serve common crawl to decrease diffuse server loads, but I’d imagine the kinds of entities capable of serving such an index would be the kinds to try and exploit users.</p> +<p>I’m thirsting for knowlege; blogs like these that are actually interesting:</p> +<ul> +<li>purplesyringa</li> +<li>joshua blais</li> +</ul> +<p>UNRELATED: I regret adding search to my Gemini protocol browser. It’s slightly complex and utterly cancerous.</p> +</body> +</html> diff --git a/posts/wip/basic-software-profiling-cpu-usage.md b/posts/wip/basic-software-profiling-cpu-usage.md @@ -1,14 +1,14 @@ # Basic Software Profiling: CPU Usage -We waste trillions of CPU cycles every day because software isn't profiled frequently. I believe this is an educational problem. +Tens of millions of human hours are wasted every day because software is slow. The most addressable contributing factor to this state of affairs is education. A specific educational problem is a lack of awareness for how to profile software. -This post will explain how you can find the parts of a program hogging the most CPU time. The post will focus on compiled programs, but the core ideas can be applied to interpreted programs. +To this end, this post will explain how you can find the parts of programs hogging the most CPU time. This post will focus on compiled programs, but the core ideas may be applied to interpreted programs. ## Tools [Perf](https://en.wikipedia.org/wiki/Perf_%28Linux%29) is a suite of tools for program profiling on Linux. We will mainly use it to collect aggregate performance metrics and call stack information. Analogous tools exist for other Free operating systems, and dedicated tools exist for many interpreted languages to collect call stack information. -[Flamegraph](https://github.com/brendangregg/FlameGraph) is a suite of tools for generating flamegraphs, a type of graph designed for the visualization of performance data. +[Flamegraph](https://github.com/brendangregg/FlameGraph) is a suite of tools for generating flamegraphs, a type of graph designed for the visualization of performance data. I use my [fork of flamegraph](https://git.laack.co/flamegraph) which doesn't add j***s***** to generated SVGs, but apart from this they function identically. ## Reading a Flamegraph @@ -164,21 +164,19 @@ This is the command I run most frequently when validating optimizations when the Start with functions using lots of CPU time that you wouldn't expect to. Often a small number of functions do the majority of computation, and these are the ones worth optimizing in the average case. To make these functions run faster, you should consider the following: 1. Can we call this function less often -2. Can each call perform less work via algorithmic improvements +2. Can each call perform less work -Both of these questions are about decreasing work, not making the work faster. Making work faster can be complex, and it's often easier to improve performance by decreasing wasted work and algorithmic improvements. +Both of these questions are about decreasing work, not making the work faster. Making work faster can be complex, so it's often easier to improve performance by removing wasted work or making algorithmic improvements. ## Case Study ### Amfora -[Amfora](https://github.com/makew0rld/amfora) is a fancy terminal-based Gemini protocol browser with syntax highlighting. Gemini is a text-based protocol which primarily distributes [gemtext](https://geminiprotocol.net/docs/gemtext.gmi) documents. These documents use a similar syntax to markdown, but a bit simpler. I chose this program to profile because software in the Gemini ecosystem is generally quite simple to understand, making it great for educational purposes. +[Amfora](https://github.com/makew0rld/amfora) is a fancy terminal-based Gemini protocol browser with syntax highlighting. Gemini is a text-based protocol which primarily distributes [gemtext](https://geminiprotocol.net/docs/gemtext.gmi) documents. These documents use a similar syntax to markdown, but its slightly simpler. I chose to profile this program because software in the Gemini ecosystem is often simple to understand, making it great for educational use cases. -When I start profiling software I often find it useful to use an oracle to understand what's possible. An oracle in this context is a program that performs comparable tasks with decent performance characteristics. +When I start profiling software I often find it useful to use an oracle to understand what's possible. An oracle in this context is a program that performs comparable tasks with decent performance characteristics. I chose [Foreseen](https://git.laack.co/foreseen/), a Gemini protocol browser I developed, as the oracle because it fulfils both criteria. -I chose [Foreseen](https://git.laack.co/foreseen/), a Gemini protocol browser I developed, as the oracle as it has adequate performance, and performs a sensible subset of the tasks performed by Amfora. - -I normally start by searching for worst case performance scenarios. Worst cases are often an amplification of an average case, so by improving worst case performance you can often improve average case performance. +I like to start by searching for worst case performance scenarios. Worst cases are often an amplification of an average case, so by improving worst case performance you can often improve average case performance. Let's look for the worst case for the task of rendering a textual document. We'll load a large text file from disk using both browsers, killing the program once the first lines of text are drawn. Since neither browser supports text streaming, they will both have to load and parse the document, and then draw some text to the terminal. To generate the document I executed the following Python code: @@ -358,7 +356,8 @@ We can go deeper still on this, but there are now 3 ~equally costly groupings, a ## What's Next -This post only discussed on-CPU time profiling. There are two additional metric,s worth profiling I'll discuss in the future: +This post only discussed on-CPU time profiling for program execution. There are a few additional metrics worth profiling that I'll discuss in the future: 1. Off CPU profiling 2. Memory profiling +3. Build profiling diff --git a/posts/wip/constrained-software-revolution.md b/posts/wip/constrained-software-revolution.md @@ -78,7 +78,7 @@ This is one distinction. There is an underserved niche of software for experienc Consider Dillo. There are advanced features, facilitated by its plugins system, but the base browser is exceptionally approachable. I'd argue it's more approachable than Chromium. I won't claim it would be preferred by many users in its present state, but slight improvements to the usage experience to keep up with modern standards (some stuff with settings and first pass rendering missing css sometimes) would certainly make it as usable or more usable. -The problem right now is most sites people patronize don't work without J***S*****. I've accepted sites like that aren't made for me, but it requires widespread disdain to make it known people are sick and tired of this. +The problem right now is most sites people patronize don't work without j***s*****. I've accepted sites like that aren't made for me, but it requires widespread disdain to make it known people are sick and tired of this. --- diff --git a/posts/wip/fault-injection.md b/posts/wip/fault-injection.md @@ -0,0 +1,8 @@ +# Fault Injection + +We accept at face value the programs we write will execute how they are written. + +What if they don't? + +Fault injection is one such case where the instructions will not be adhered to +as expected. diff --git a/posts/wip/my-favorite-piece-of-software.md b/posts/wip/my-favorite-piece-of-software.md @@ -39,7 +39,7 @@ To start, I'd like to list the software I use frequently that I don't detest. Th ## Filtering -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 *controlled* environment), but I also realize it is a requirement for the modern web, and sometimes I am compelled to use some modern websites. +I like Lynx quite a bit, but most of the other browsers feel like the lesser of evils. In particular, I don't think j***s***** on the web is a good idea, but I also realize it is a requirement for the modern web, and sometimes I am compelled to use some modern websites. 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. diff --git a/posts/wip/posix-shell-jobs.md b/posts/wip/posix-shell-jobs.md @@ -0,0 +1,33 @@ +# POSIX Shell Jobs + +There are lots of bloated terminal multiplexers and persistence programs, like +zellij, tmux, screen, and the new age vibe-coded slop ones. These are all bloat. + +It turns out POSIX shell has a lot of this built in. + +## The Stack + +- st +- bash / dash / ash +- optional: abduco + +That's it. That's all you need to have the same features as tmux, zellij, +ghostty (gross) all in one. + +## Writing Code + +When writing code I used to use a tmux pane with my editor, one with a terminal +for execution, and sometimes another with lynx open, as relevant. Since then, +I've become annoyed by this because I'd much rather have one bash session that +does everything instead of dealing with the bloated monstrosity that is tmux. + +Instead I do this: + +- write code in vim +- C-z it to suspend the program +- Run my commands in the newly cleaned bash session +- Run 'fg' to foreground the suspended session. + +``` +[andrew@hal wip]$ jobs -l +``` diff --git a/posts/wip/search-is-the-problem.md b/posts/wip/search-is-the-problem.md @@ -0,0 +1,41 @@ +# (Centralized) Search is the Problem + +Search engines killed the useful, interesting internet. All corners of the www +have been infested by companies astroturfing, people with dumbass agendas, and +AI slop (no, your slop isn't different, no you don't hold it differently, it's +all fucking slop, stop kidding yourself). + +Why did this happen? Put simply, I believe this is because of search engines. +Search engines attempt to answer queries from a diffuse set of sources, and +since this is how most people use the internet, it is a high value target. It +has since been solved as a problem. You will never find a blog post of mine in +search results, but you'll find some slop top ten list, even if you search the +exact name of my post, which are indexed by search engines mind you. I guarantee +my posts are at least better than the average search result quality because I'm +not a sell-out, but you won't find them. I won't bend the knee to use shady +tactics to rank better at the cost of informational quality, and so here I +stand. + +This leads me to this: what's the best way to find works from people like me? +Distributionally, there's nothing special about my or anyone else's blog posts +that couldn't be co-opted by special interests, so the solution is to not use +search engines, or at least ones that are calibrated in this way. It's possible +personal search engines could work, ones that index good parts of the web in a +selective way, but this isn't well done yet. + +Given this, it seems that discovery is relegated to being your own spider. +To be your own spider takes effort, but it's to the point that the web is so +utterly fucking useless that I don't know what else is left. + +Perhaps an alternative could be some sort of self-serve common crawl to decrease +diffuse server loads, but I'd imagine the kinds of entities capable of serving +such an index would be the kinds to try and exploit users. + +I'm thirsting for knowlege; blogs like these that are actually interesting: + +- purplesyringa +- joshua blais + +UNRELATED: +I regret adding search to my Gemini protocol browser. It's slightly complex +and utterly cancerous.