<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Everything Flows</title>
	<atom:link href="https://lukerodgers.ca/feed/" rel="self" type="application/rss+xml" />
	<link>https://lukerodgers.ca</link>
	<description></description>
	<lastBuildDate>Sat, 05 Oct 2024 12:07:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lukerodgers.ca' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s0.wp.com/i/buttonw-com.png</url>
		<title>Everything Flows</title>
		<link>https://lukerodgers.ca</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://lukerodgers.ca/osd.xml" title="Everything Flows" />
	<atom:link rel='hub' href='https://lukerodgers.ca/?pushpress=hub'/>
	<item>
		<title>Conscientiousness and IQ</title>
		<link>https://lukerodgers.ca/2024/10/05/conscientiousness-and-iq/</link>
					<comments>https://lukerodgers.ca/2024/10/05/conscientiousness-and-iq/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sat, 05 Oct 2024 12:07:30 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=1074</guid>

					<description><![CDATA[There seems to be little agreement amongst scientists on the relation between these factors:]]></description>
										<content:encoded><![CDATA[
<p>There seems to be little agreement amongst scientists on the relation between these factors:</p>



<ul class="wp-block-list">
<li>2014 <a href="https://www.sciencedirect.com/science/article/abs/pii/S0191886914003432">How are conscientiousness and cognitive ability related to one another? A re-examination of the intelligence compensation hypothesis</a> &#8211; &#8220;true association between these constructs may be zero or positive at the population level but that the use of selected research samples has sometimes resulted in the appearance of a negative association.&#8221;</li>



<li>2006 <a href="https://www.sciencedirect.com/science/article/abs/pii/S1041608015001740">Is conscientiousness positively or negatively related to intelligence? Insights from the national level</a> &#8211;  &#8220;Self-report conscientiousness scores are negatively associated with IQ&#8221; while &#8220;Observer-rated conscientiousness scores tend to positively correlate with IQ.&#8221;</li>



<li>2015 <a href="https://www.sciencedirect.com/science/article/abs/pii/S0191886903004380">Why is Conscientiousness negatively correlated with intelligence?</a> &#8211; &#8220;the negative relationship between intelligence and Conscientiousness is due to fluid intelligence affecting the development of Conscientiousness, in an educated and need-achieving population&#8221;</li>



<li>2014 <a href="https://www.sciencedirect.com/science/article/abs/pii/S0191886914003018">The social influences on trait Conscientiousness: Findings from a nationally representative sample</a> &#8211; &#8220;a significant, but very small positive association between intelligence, social factors and Conscientiousness.&#8221;</li>



<li>2023 <a href="https://www.hrp-journal.com/index.php/pru/article/view/531">Conscientiousness and Cognitive Abilities: a Meta-Analysis</a> &#8211; &#8220;Several random-effects meta-analyses were conducted, obtaining meta-analytical correlations of .02, -.06 and -.06 between Conscientiousness (global) and cognitive abilities (global), crystallized intelligence and fluid intelligence, respectively.&#8221; Unclear why they exclude studies that do NOT &#8220;report any link between Conscientiousness and cognitive ability&#8221;, that seems like a &#8220;fail to reject the null hypothesis&#8221; result that should be very relevant?</li>
</ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2024/10/05/conscientiousness-and-iq/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>Notes on Notes on Complexity</title>
		<link>https://lukerodgers.ca/2024/06/06/notes-on-notes-on-complexity/</link>
					<comments>https://lukerodgers.ca/2024/06/06/notes-on-notes-on-complexity/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Fri, 07 Jun 2024 01:08:13 +0000</pubDate>
				<category><![CDATA[curmudgeonly writings]]></category>
		<category><![CDATA[philosophy]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=1063</guid>

					<description><![CDATA[A critical review of Notes on Complexity by Neil Theise. The goal of this book seems to be twofold: It achieves the first goal, and comes nowhere close the second. Overall I found the book to be engaging and well-written, if poorly argued at some of its most important points. I am bothering to write [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>A critical review of <em>Notes on Complexity</em> by Neil Theise.</p>



<p>The goal of this book seems to be twofold:</p>



<ol class="wp-block-list">
<li>to expose the lay reader to the world of complexity theory and science</li>



<li>to argue that the true nature of reality is, in some sense, &#8220;consciousness&#8221; and that this is somehow realted to complexity theory</li>
</ol>



<p>It achieves the first goal, and comes nowhere close the second.</p>



<p>Overall I found the book to be engaging and well-written, if poorly argued at some of its most important points. I am bothering to write up these reflections because I think it is a good representative of the late 20th, early 21st century flavour of &#8220;let&#8217;s show how some surprising discoveries from Western science like quantum mechanics actually jive in a postmodern way with a pastiche of religious and pseudo-religious wisdom&#8221;. I am using wisdom not in quotes here and non-ironically, in that I do think religious traditions can be sources of wisdom. But the rest of that quote gives an accurate sense as to how generally non-rigorous I think these approaches are.</p>



<p>I am all for attempting to bridge religion and sicence in a vaguely CP Snow&#8217;s &#8220;Two Cultures&#8221; kind of way, but I can&#8217;t presently recall ever having encountered the fruits of such an effort that didn&#8217;t fall almost completely flat.</p>



<p>The book starts out well, providing a lucid introduction to complexity theory. The part I found most interesting was the idea that some amount of randomness or unpredictability was key to complex systems. Theise introduces the term &#8220;quenched disorder&#8221; as a level of randomness that is sufficiently in between extremes that it permits for adaptibilty through random discovery of new paths/behaviours, while not collapsing into chaos due to lack of structure or predictabiltiy.</p>



<p>Next Theise brings us into the world of cells, which as a pathologist is his area of expertise. He asks us to consider looking at a body, then zooming into its cells; or looking at an ant colony from afar, then zooming into a single ant, and the futher still to its cells. At each level we encounter a complex self-organizing system, and there is no real answer to the question of which is the &#8220;right&#8221; level. Whether you&#8217;re looking at a single thing or a phenomenon is a matter of perspective, it is both at once.</p>



<p>This doubling Niese argues is related to what physicists call complementarity. This is most familiar to us from the wave-partical duality demonstrated by the slit experiment.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Bohr, however, went further, asserting that complentarity was fundamental not just for describing existence at the incredibly minute scales of the quantum realm but for describing living beings at our normal everyday scale as well.</p>
</blockquote>



<p>At this point in the text a footnote references an article by Theise in Nature vol 435. Curiously the single-page essay (not a peer-reviewd article) doesn&#8217;t mention Bohr at all. Not clear if this is an editing error or what, but a brief foray into some secondary literature on the web (most of it admittedly not high quality) suggests that Bohr was indeed taken with the idea that the principle of complementarity was not only relevant at the quantum scale. At this point this isn&#8217;t a direct &#8220;appeal to authority&#8221; fallacy, though it is sort of skirting close to that.</p>



<p>Theise elaborates from this</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>The realization that one&#8217;s body is a unitary entity by itself, but also, equally, not, has important implications. One is that the boundary of one&#8217;s body starts to become indistinct. At the everyday scale, my boundary is my skin and your boundary is your skin. Close your eyes and feel how your fingers meet this book or the device on which you are reading it. You feel a sharp, distinct edge between you and the not-you where skin meets object. But at the microscopic level, just how sharp and distinct is the surface of your skin? Not very distinct at all. Cells from the top layer are constantly shedding as they die. Much of the dust of our homes, in fact, consists of sloughed off cells from our skin… At the microscopic level, we are thus not actually bounded by the top of our skins. Our boundaries are at least as broad as the spaces we inhabit. (p 48)</p>
</blockquote>



<p>Here is where I begin to take issue with Theise&#8217;s argument.</p>



<h2 class="wp-block-heading">Boundaries, boundaries everywhere, as far as the eye can see… or not at all</h2>



<p>Simply because our skin cells slough off and coagulate into dust bunnies, how does that mean the boundary of my body has somehow extended to behind my dresser? This is absurd. It&#8217;s about as cogent as when my daughter says that because she has touched her finger to her tongue and then her finger to the floor, her tongue is therefore on the floor.</p>



<p>Maybe Theise could have argued that the microorganisms living on our skin and hair can have physical interactions with the world beyond us that then somehow influence our own bodies&#8217; perceptive ability or homeostatic state&#8211;this may well be the case, and would be a stronger point in his favour, but still results in the boundary of our body basically being exactly what we thought it was, plus a couple micrometers here and there to accommodate the volume of these microorganisms.</p>



<p>There may well be other more compelling arguments for how the boundaries of our bodies are less rigid than we usually think (and I am generally open to arguments from the extended mind/extended cognition world that our minds may be fruitfully considered to have a fuzzier and wider boundary than we think), but that is not the argument Thesis makes here. The argument he does make is entirely unconvincing so far.</p>



<p>Theise attempts to expand this argument via the bacterial microbiomes that inhabit our guts and reside on the surface of our skin.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>The microbiome doesn&#8217;t only colonize us; it is integral to our living, healthy bodies… These organisms… travel from us whenever we touch something. Doornobs, cell phones, counteropts, pens, each other. Every time you shake hands with, kiss, or hug someone else, some of &#8216;you&#8217; gets left behind and some of the person you touched travels away with you. This process of bacterial exchange is so pronounced that the microbiomes of people (and pets) who live together become one giant shared microbiome, an continuous multcellular entity enveloping the human (and dog and cat) islands… if we keep this fact about or shared microbiomes in mind, the boundaries between ourselves and what&#8217;s outside our skin start to look even blurrier</p>
</blockquote>



<p>Does one giant, shared, boundary-less microbiome really emerge in this case? Going back to Theise&#8217;s earlier arguments about perspective, I would agree that it is possible to imagine a perspective in which that is the case. From a certain, distant point of view, one might look at some cohabitating humans, dogs, etc and say &#8220;wow that&#8217;s a bunch of mixed up bacteria&#8221;. But note that this doesn&#8217;t fit into the &#8220;zooming out&#8221; metaphor Theise used earlier: we can&#8217;t both &#8220;zoom out&#8221; to see humans, pets and bacteria all at the same time, since they are only perceptible on vastly different scales. If we &#8220;zoom in&#8221; close enough that we see bacteria, we would in fact not see a shared, unitary, boundary-less microbiome at all, but rather one full of fairly sharp discontinuities. E coli in the intestines, but basically nowhere else, Staphylococcus on the skin but basically nowhere else, minimal bacteria in the air between bodies, and so on. We would see boundaries everywhere.</p>



<p>Is there a scientific perspective according to which it is particularly useful to see this situation as a single, boundaryless microbiome? Theise has certainly not given us any reason to think so. Even if he could, this doesn&#8217;t mean that the boundaries of our skin or bodies have suddenly evaporated, it simply means there are ways of exchanging parts of our bodies across those boundaries. Just because a medieval fortification could permit egress and ingress through gates in its walls does&#8217;t mean those walls don&#8217;t exist all of a sudden. If attackers discovered that every block in the wall could be passed through simply as if it did not exist, then it would make sense to say there is no boundary. And if biologists discovered that our skin permitted every particle and microorganism to move through it, then we&#8217;d say &#8220;wow there really is no boundary&#8221; but of course that is not remotely the case.</p>



<h2 class="wp-block-heading">Everything is everything</h2>



<p>Theise attempts a similar argument across time: how can we draw a boundary between our selves now, and yesterday, and back to an embryo, and then back to our parents as embryos, ad infinitum. Hegel rightly criticized this sort of muddled thiking about 2 centuries ago as the &#8220;night in which all cows are black&#8221;. In this vein of thought, I guess we&#8217;d say that desks and spoons and wooden jewelry carved from the lumber from a single tree really just are that tree which is a fun way of thinking when you&#8217;re high but if you try eating your soup with a toothpick or sitting down to study with your books on your ladle you will find that accepting the reality of these boundaries is a much more useful way of thinking. It is of course possible to think in the other &#8220;everything is one&#8221; way, and doing so can provide valuable ethical motivation and contemplative satisfaction, but in most everyday cases is is not a useful way of looking at the world, and is certainly not &#8220;truer&#8221; than any other way.</p>



<p>In the next chapter, Theise attempts to provide some scientific motivation for complementarity from his own area of expertise. He imagines a world in which rather than microscopes having first revealed to us cells with their walls separating them from each other, some alternate microscope technology in which we first see the nucleii floating in an undivided fluid, and only later discover cell walls.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>In this alternate history, the fluid doctrine would have been born as the foundational paradigm of Western medicine and biology. In the years that followed, after applying special stains and seeing cell membranes for the first time, these scientists wouldn&#8217;t have backtracked, saying, &#8220;Oh, we were wrong, the body is made of cells.&#8221; They would have instead said something like, &#8220;Oh look, there is a semipermeable membrande partitioning of the body&#8217;s fluid continuum.&#8221;</p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>So which is it? Is the body made of discrete cells or is it a fluid continuum? Yet again, we find a complementarity. The two different views illumiante different truths of our bodies. Each view captures aspects that are hidden by the other, while at the same time concealing details the other view reveals. Once more, a complete understanding of the whole depends on both views, equally, even though they seem contradictory.</p>
</blockquote>



<p>First of all, it is entirely possible that scientists would have backtracked in this hypothetical scenario. Scientists once held to various fluid theories of heat, which were later rejected in favour of mechanical theories that better explained experimental observations.</p>



<p>Theise here makes the claim that the fluid view captures something hidden by the other view, but doesn&#8217;t tell us what this is, nor why whatever insights it reveals couldn&#8217;t be equally adequately expressed in the cell model. This is of course a book for a lay audience and Theise is an expert, so we can grant him some benefit of the doubt that there are such facts or insights.</p>



<p>But we should at least expect an argument that these views are incompatible in the same way that the wave/particle duality shows an incompatibility: the wave behaviour is literally impossible if the light were behaving as a particle, and yet it is both. In this case though, there is no assertion that some observed behaviour or property is completely inexplicable and physically mystifying from one point of view and only explicable from the other point of view.</p>



<p>As some evidence in support something like a fluid model, Theise offers us acupuncture which has effects that are &#8220;testable and reproducible&#8221; but have not been sufficiently explained by standard anatomy or by the cell doctrine.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Anatomically, those acupoints do not correspond to any nerves, blood vessels, lymphatics, or any other apparent anatomic structure… The cell doctrine seems unable to explain acupuncture then, but thinking of the body as a fluid might provide useful insights.</p>
</blockquote>



<p>Contrariwise, there is a surfeit of researching attempting to, and claming some success with, explaining the effectiveness of acpuncture on the basis of Western biology, e.g. <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8991130/">Understandings of acupuncture application and mechanisms</a>.</p>



<h2 class="wp-block-heading">Nothing is anything</h2>



<p>Somewhat subtly, but without sufficient justification, Theise eventually moves from a discussion of complementarity and alternate perspectives to absolute claims like:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>We have searched deep into the smallest recesses of existence&#8211;down into the quantum foam and space-time itself&#8211;and nowhere could we find an object with inherent existence in and of itself.</p>
</blockquote>



<p>What would it mean for something to exist &#8220;in and of itself&#8221;? Theise doesn&#8217;t tell us, and I&#8217;d rather not blame him for not being a philosopher, except that he has now transitioned firmly into the realm of metaphysics, making sweeping claims about the nature of reality. His brand of metaphysics is, perhaps surprisingly, not particularly post-modern or new agey, it is the old claim that only the fundamental entities (perhaps he would rather say phenomena) of physics are real, and everything else is a sort of mirage based upon them. From this point of view it is also not surprising that he finds sufficient overlap between his theses and ancient religious wisdom, which also sees everyday objects and concerns as unreal shadows of an underlying, fundamental (usually mystical) reality.</p>



<p>The book is not done at this point, but I am done arguing with it.</p>



<p>I suppose my main gripes with this book could be condensed to</p>



<ul class="wp-block-list">
<li>I believe with George Box that &#8220;all models are wrong, some are useful&#8221;, and that this should be the stance of the scientist and generally <em>is</em> unless they are waylaid by the (reasonable, and probably unavoidable) temptation to make claims for the absolute truth of their preferred models</li>



<li>Theise believes instead that he has discovered the true model of reality</li>



<li>But all of his arguments along the way to this conclusion fall apart quickly under any sort of scrutiny</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2024/06/06/notes-on-notes-on-complexity/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>Avoid Rails console sandbox</title>
		<link>https://lukerodgers.ca/2024/01/19/avoid-rails-console-sandbox/</link>
					<comments>https://lukerodgers.ca/2024/01/19/avoid-rails-console-sandbox/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sat, 20 Jan 2024 03:42:33 +0000</pubDate>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web and tech]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=1049</guid>

					<description><![CDATA[The rails console is a powerful tool. It provides a repl into your application, allowing you to run and debug code, and interact with your database. The code reloading functionality isn&#8217;t as nice as what you&#8217;d get with a lisp, but generally you&#8217;re a single reload! away from getting whatever changes you&#8217;ve made in your [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The rails console is a powerful tool. It provides a repl into your application, allowing you to run and debug code, and interact with your database. The code reloading functionality isn&#8217;t as nice as what you&#8217;d get with a lisp, but generally you&#8217;re a single <code>reload!</code> away from getting whatever changes you&#8217;ve made in your editor loaded into the current rails console session, ready to use.</p>



<p>It also has a <a href="https://guides.rubyonrails.org/command_line.html#bin-rails-console">sandbox mode, which is briefly mentioned in the official rails docs</a>, and is well-described here <a href="https://www.mintbit.com/blog/the-power-of-rails-console-with-the-sandbox-option">The Power of Rails Console with the &#8211;sandbox Option</a>. </p>



<p>However, it comes with a big gotcha &#8211; one that is so problematic that the feature should in my opinion not even exist. (DHH&#8217;s philosophy is to &#8220;provide sharp knives&#8221; even if if the developer may cut themselves &#8212; fine but if we want to use that metaphor, this is a sharp knife that will eventually give you tetanus.)</p>



<p>The way it provides safety against accidentally modifying data is by wrapping everything you do in a database transaction, then just rolling that transaction back at the end of your session. This will work, and isn&#8217;t an unreasonable thing to do, but depending on what database you&#8217;re using, it will increase the likelihood of other queries and database operations failing or deadlocking. </p>



<h2 class="wp-block-heading">Postgres table locks</h2>



<p>With postgres, whenever you read from a table in a transaction, it will automatically take an <code>ACCESS SHARE</code> lock on that table (and its indexes, as far as I can tell), as per the docs on <a href="https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES">table-level locks</a>. This is the lowest level of lock (as in, the one that conflicts with the fewest other lock modes), so it won&#8217;t prevent other transactions in other processes from normal querying, but it will prevent other processes from doing anything that requires an <code>ACCESS EXCLUSIVE</code> lock, for example many table and index operations. These will all fail to execute due to your sandboxed rails console, and will be taken if are you doing pretty much anything at all involving the database in your console session. </p>



<h2 class="wp-block-heading">Postgres row locks</h2>



<p>If, in your sandboxed rails console session, you accidentally or intentionally update some rows, this will (in addition to table level locks) take a row-level lock on the rows you are modifying. The precise lock level will depend on the nature of the field you are modifying (mostly, whether it is indexed or not) but either way, you can still run into a situation where your sandbox session causes other transactions to either hang or deadlock. </p>



<p>Consider the this case:</p>



<ul class="wp-block-list">
<li>your console session starts, and you modify user 1&#8217;s name to &#8220;foo&#8221;, acquiring lock 1a on this row</li>



<li>an application session starts a transaction, and modifies user 2&#8217;s name to &#8220;bar&#8221;, acquiring lock 2a on this row</li>



<li>your console session then modifies user 2&#8217;s name to &#8220;foo2&#8221;, attempting to acquire lock 2b on the same row; this has to wait on lock 2a to be released</li>



<li>the same application transaction attempts to modify user 1&#8217;s name to &#8220;bar2&#8221;, attempting to acquire lock 1b on that row</li>



<li>we now have a deadlock, as there is a cycle in the lock dependency graph. postgres will detect this and abort one of the transactions, with no guarantee as to which one will be selected for termination</li>
</ul>



<h2 class="wp-block-heading">Other reasons</h2>



<p>Even if you aren&#8217;t concerned about interfering with DDL statements modifying the database schema, or you &#8220;know&#8221; you won&#8217;t be modifying data, so don&#8217;t have to worry about deadlocks, long running transactions are problematic for various reasons, including preventing vacuum and <a href="https://www.percona.com/blog/replication-lag-in-postgresql/">potentially introducing replication lag</a>.</p>



<h2 class="wp-block-heading">What about mysql and other databases?</h2>



<p>My familiarity is primarily with postgres, and the mysql docs are not as clear on this point, but <a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html">Transaction Isolation Levels</a> does state that at the <code>READ COMMITTED</code> (and above, presumably) isolation level, innodb will hold &#8220;locks only for rows that it updates or deletes&#8221;, so I suspect rails console sandbox on mysql will have most of the same problems as postgres.</p>



<h2 class="wp-block-heading">What to do instead?</h2>



<p>Instead of this, you can create a read only postgres (or mysql) user, and have the rails console session use that instead. This could be configured by an environment variable, or an interactive startup script you run before enabling a console session. </p>



<p>This way, you get the safety of preventing any accidental data modification, while avoiding the most serious pitfalls: causing your application queries to deadlock or hang. However, your console queries will still take table level locks which will block table modification and related operations.</p>



<p>You can reduce that risk by keeping your rails console sessions short, but the best solution is just to not use the rails console in production at all.</p>



<ul class="wp-block-list">
<li>Ensure you have a staging (or similar) environment that includes a copy (or subset) of your production data, scrubbed of any sensitive info like credentials, access tokens, and PII.</li>



<li>And/or, set up replication to another database and do all your queries on it, or even extract your data to a warehouse for analytical querying. </li>
</ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2024/01/19/avoid-rails-console-sandbox/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>A plea to reconsider sampling Alan Watts in your lowfi chillwave music</title>
		<link>https://lukerodgers.ca/2024/01/06/a-plea-to-reconsider-sampling-alan-watts-in-your-lowfi-chillwave-music/</link>
					<comments>https://lukerodgers.ca/2024/01/06/a-plea-to-reconsider-sampling-alan-watts-in-your-lowfi-chillwave-music/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sat, 06 Jan 2024 15:59:39 +0000</pubDate>
				<category><![CDATA[acoustical things]]></category>
		<category><![CDATA[things about which I am not ambivalent]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=987</guid>

					<description><![CDATA[I use Spotify primarily for listening to wordless music while I work, and it does a pretty great job of recommending things I will want to listen to. Except that there seems to be a trend (maybe it is over now? maybe these are just sonic echoes of a thankfully bygone era?) of digital music [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I use Spotify primarily for listening to wordless music while I work, and it does a pretty great job of recommending things I will want to listen to.<br><br>Except that there seems to be a trend (maybe it is over now? maybe these are just sonic echoes of a thankfully bygone era?) of digital music composers ruining their music with snippets from Alan Watts admonishing us to not take things for granted, or marvel at the mystery of experience, or only do things we enjoy doing.</p>



<p>I&#8217;m not sure if the Spotify algorithm thinks I like the Alan Watts stuff, or if it just crops up so frequently in the type of music I <em>do</em> want to listen to that it is unavoiable.</p>



<p>When I click the button to tell Spotify &#8220;I don&#8217;t like this song&#8221; and it says &#8220;Okay, we won&#8217;t recommend things like this again&#8221; does it understand that by &#8220;things like this&#8221; I just mean &#8220;songs with Alan Watts&#8221;, literally just that?</p>



<p>You see my dilemma. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2024/01/06/a-plea-to-reconsider-sampling-alan-watts-in-your-lowfi-chillwave-music/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>Database write amplification</title>
		<link>https://lukerodgers.ca/2023/12/30/database-write-amplification/</link>
					<comments>https://lukerodgers.ca/2023/12/30/database-write-amplification/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sat, 30 Dec 2023 15:20:00 +0000</pubDate>
				<category><![CDATA[web and tech]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=1028</guid>

					<description><![CDATA[I&#8217;m writing this in the spirit of Cunningham&#8217;s law: &#8220;the best way to get the right answer on the internet is not to ask a question; it&#8217;s to post the wrong answer.&#8221; I suspect there are inaccuracies here, and will amend when informed of them. I was reading PostgreSQL Internals: 3 Things to Know About [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><em>I&#8217;m writing this in the spirit of Cunningham&#8217;s law: &#8220;the best way to get the right answer on the internet is not to ask a question; it&#8217;s to post the wrong answer.&#8221; I suspect there are inaccuracies here, and will amend when informed of them.</em></p>



<hr class="wp-block-separator has-alpha-channel-opacity" />



<p>I was reading <a href="https://patrick.engineering/posts/postgres-internals/">PostgreSQL Internals: 3 Things to Know About UPDATE Statements</a> which begins with a nice, succinct discussion of how Postgres&#8217; MVCC design results in write amplification. Basically, updates to rows are not made &#8220;in place&#8221; but rather by writing complete new versions of the row. Depending on the columns of a given table, and what is being updated, modifying a single byte (e.g. for a boolean column) can lead to a write amplification factor of several orders of magnitude, if the row also contains &gt; 100-byte <code>varchar</code> columns, since a completely new copy of the row is written, along with the changes, and the old row is vacuumed later.</p>



<p>This reminded me of the article from <a href="https://www.uber.com/blog/postgres-to-mysql-migration/">Uber several years ago on why they switched from Postgres to MySQL</a>, one of the main reasons being write amplification. But Postgres is not alone in using MVCC to provide ACID guarantees, MySQL uses MVCC as well, albeit a fairly different implementation. But then, if that&#8217;s the case, how does MySQL avoid write amplification.</p>



<h2 class="wp-block-heading">MySQL write amplification?</h2>



<p>According to <a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-multi-versioning.html">MySQL&#8217;s docs on InnoDB Multi-Versioning</a>, MySQL like Postgres uses multiple versions of the same row to service concurrent queries. But rather than writing entirely new row copies, MySQL uses <em>undo logs</em> which are maintained in a <a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-undo-tablespaces.html">separate undo tablespace,</a> used both for transaction rollbacks and to &#8220;build earlier versions of a row for a consistent read.&#8221; </p>



<p>This latter statement suggests that rather than storing an entire copy of old data, something like a changelog is maintained, which can be used to reconstruct the old version of the row at read time. The docs link to <a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-multi-versioning.html">Consistent Nonlocking Reads,</a> but this covers just the API/expected use rather than the implementation details. We also read that &#8220;The physical size of an undo log record in the rollback segment is typically smaller than the corresponding inserted or updated row&#8221; which further suggests that undo logs don&#8217;t contain full copies, but also that they aren&#8217;t just a changelog or ordered list of diffs either. </p>



<p>For a more in-depth view of InnoDB, we can turn to <a href="https://www.alibabacloud.com/blog/an-in-depth-analysis-of-undo-logs-in-innodb_598966">An In-Depth Analysis of UNDO Logs in InnoDB</a>. Summarizing the relevant parts:</p>



<ul class="wp-block-list">
<li>InnoDB has 3 different types of undo record, and the &#8220;update&#8221; type appears to support a dynamic number of &#8220;update fields&#8221; which indeed do seem to function like a changelog. So if we are changing just one column on a row, rather than copying the whole row, InnoDB just creates a new undo log entry with the changed data.</li>



<li>As explained in section 7 of the article, &#8220;Undo for MVCC&#8221;, as we suspected a transaction will (using its own transaction ID and the set of visible transaction IDs it is assigned at start time) walk back through a row&#8217;s undo log to find relevant versions and reconstruct them to return the correct result (according to the isolation level). </li>
</ul>



<h3 class="wp-block-heading">Performance implications</h3>



<p>So we can surmise from this, with some educated guessing:</p>



<ul class="wp-block-list">
<li>Given that the MySQL undo log only writes the changed fields rather than copying whole rows, it is plausible that, depending on the nature of writes and table structure, this will indeed result in less write amplification than Postgres&#8217; MVCC approach. </li>



<li>But note that the MySQL undo log entries also contain a fair amount of header (and footer) metadata. For a small Postgres table (e.g. only a couple int/byte columns) it&#8217;s plausible that Postgres&#8217; MVCC approach would actually use less space by copying the whole row.</li>



<li>For situations with several open transactions, each of which have modified different columns of a row, a reader will probably have to do more work to reconstruct the result with MySQL vs Postgres.
<ul class="wp-block-list">
<li>On the other hand, the actual performance impacts of this will probably largely depend on how the data is stored. If old Postgres tuples are stored scattered across multiple pages, compared to MySQL which seems to store these undo log entries generally close together in a dedicated tablespace, then Postgres&#8217; algorithm might be faster from a Big O notation point of view, but could perform worse in practice due to poor data locality, in other words, read amplification.</li>
</ul>
</li>



<li>Some other aspects of the MySQL approach seem like they could lead to problems, like limitations to the number of undo log entries which presumably limit the number and range of open transactions, but I&#8217;m not going to dig into that now. </li>
</ul>



<figure class="wp-block-image size-large"><img width="505" height="230" data-attachment-id="1037" data-permalink="https://lukerodgers.ca/2023/12/30/database-write-amplification/screenshot-2023-12-30-at-10-05-02-am/" data-orig-file="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png" data-orig-size="505,230" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="screenshot-2023-12-30-at-10.05.02-am" data-image-description="" data-image-caption="" data-medium-file="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png?w=300" data-large-file="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png?w=505" tabindex="0" role="button" src="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png?w=505" alt="" class="wp-image-1037" srcset="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png 505w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png?w=150 150w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png?w=300 300w" sizes="(max-width: 505px) 100vw, 505px" /></figure>



<p>But thinking back to the Uber article, the write amplification they are focused on is a very different type, having nothing explicitly to do with MVCC. Instead, it&#8217;s all about how Postgres must update all indexes when a row is modified, even if you are only modifying non-indexed columns. Postres has since introduced (or improved) support for something called Heap Only Tuple (HOT) updates, which are covered well here <a href="https://www.adyen.com/knowledge-hub/postgresql-hot-updates">Fighting PostgreSQL write amplification with HOT updates</a>. </p>



<p>My main takeaway from looking into this is that write amplification can and does happen in various places. &#8220;Solving&#8221; it will often be a matter of shuffling it around or increasing read amplification, rather than just making it go away. This reminds me of fan-out vs fan-in approaches to implementing &#8220;news feed&#8221; style features: do you make reads fast for everyone, by having every new post write to all the followers&#8217; feeds, thereby making writes slow (fanout, write amplification)? Or do you make write fast, but reads slow by having them query all the followee&#8217;s post list (fan in, read amplification)? In practice I remember reading that Twitter did some of both, doing fanouts for most users, but doing fan-ins for high-follower-count users, so that Justin Bieber didn&#8217;t cause downtime whenever he tweeted. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2023/12/30/database-write-amplification/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>

		<media:content url="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-30-at-10.05.02-am.png?w=505" medium="image" />
	</item>
		<item>
		<title>Optimum ISP is MITMing its customers</title>
		<link>https://lukerodgers.ca/2023/12/09/optimum-isp-is-mitming-its-customers/</link>
					<comments>https://lukerodgers.ca/2023/12/09/optimum-isp-is-mitming-its-customers/#comments</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sat, 09 Dec 2023 12:54:35 +0000</pubDate>
				<category><![CDATA[annoying things]]></category>
		<category><![CDATA[web and tech]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=1013</guid>

					<description><![CDATA[A Man In the Middle (MITM) attack is basically when an attacker stealthily interposes itself between you and another agent (person, server, etc), and intercepts and possibly alters the communication. Normally the bailiwick of cybercriminals or Advanced Persistent Threats and Nation-State Actors, turns out this is commonly done by our ISPs as well. I was [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>A <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">Man In the Middle (MITM)</a> attack is basically when an attacker stealthily interposes itself between you and another agent (person, server, etc), and intercepts and possibly alters the communication. Normally the bailiwick of cybercriminals or <a href="https://www.cisa.gov/topics/cyber-threats-and-advisories/advanced-persistent-threats-and-nation-state-actors">Advanced Persistent Threats and Nation-State Actors</a>, turns out this is commonly done by our ISPs as well.</p>



<p>I was browsing the web this morning and visited <a href="https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/">this page about the CHERI project</a>. That page is hosted on the University of Cambridge website and should be completely safe to visit.</p>



<p>However, when I loaded it up on my iPhone, I saw a banner from Optimum advertising their free upgrade to faster internet. (I believe this is known as a <a href="https://portswigger.net/web-security/dom-based/javascript-injection">DOM injection attack</a>.) I had a literal WTF moment as this should be impossible. The website is served over HTTPS which should mean that, unless someone has broken the crypto underling modern TLS, even my ISP, which sees all of my internet traffic, should be incapable of decrypting and modifying any of that traffic. </p>



<p>But what if that website loads some resources <em>not</em> via HTTPS? I opened up the debugger&#8217;s networking tab on a Firefox desktop browser window, loaded that site, and sure enough, there is a plain HTTP request to a single resource. (Oddly I am not able to reproduce this consistently, nor at all with Chrome.)</p>



<figure class="wp-block-image size-large"><img width="1024" height="48" data-attachment-id="1020" data-permalink="https://lukerodgers.ca/2023/12/09/optimum-isp-is-mitming-its-customers/screenshot-2023-12-09-at-7-10-05-am/" data-orig-file="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png" data-orig-size="2541,121" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="screenshot-2023-12-09-at-7.10.05-am" data-image-description="" data-image-caption="" data-medium-file="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=300" data-large-file="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=1024" tabindex="0" role="button" src="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=1024" alt="" class="wp-image-1020" srcset="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=1024 1024w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=1008 1008w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=2016 2016w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=150 150w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=300 300w, https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=768 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>So what probably happened is</p>



<ul class="wp-block-list">
<li>Optimum saw an unencrypted HTTP request</li>



<li>fingerprinted my request by IP address and perhaps some other mechanisms</li>



<li>determined that it had not already sent me that advertisement</li>



<li>injected some Javascript into the content of that request</li>



<li>the Javascript payload added a little banner at the top of the page I was viewing notifying me of the newer, faster internet speeds</li>
</ul>



<p>When I got past the initial shock, I recalled that I had read about something like this before, and was able to track down a post from hackernews <a href="https://rietta.com/blog/comcast-insecure-injection/">Xfinity is Man-in-the-Middle (MITM) Attacking my Internet</a> from 2019. See also <a href="https://www.privateinternetaccess.com/blog/comcast-still-uses-mitm-javascript-injection-serve-unwanted-ads-messages/">Comcast still uses MITM javascript injection to serve unwanted ads and messages</a> from 2016.</p>



<p><a href="https://news.ycombinator.com/item?id=21391533">This commenter</a> on the Xfinity post purports to have knowledge of the details of how Comcast&#8217;s &#8220;User Messaging&#8221; feature works, via a network appliance that is operated by other ISPs as well. I&#8217;m unable to find any more information on the internet about what this appliance might be, who makes it, etc. </p>



<p>It isn&#8217;t hard to find software that does this sort of thing at the org/corporate level, e.g. <a href="https://help.ivanti.com/ps/help/en_US/VTM/22.x/userguide/ps-vtm-userguide/ssl_decryption_1.htm#sslencryption_2999580148_616880">Ivanti Traffic Manager</a> can &#8220;decrypt and re-encrypt SSL traffic dynamically&#8221;, and there is probably a raft of Cisco hardware and software that can do the same things. But I haven&#8217;t been able to find anything specifically for ISPs that would support this functionality. The closest thing is this document on <a href="https://www.cisco.com/c/en/us/td/docs/routers/sdwan/configuration/policies/vedge-20-x/policies-book/deep-packet-inspection.html">Cisco SD WAN technology</a> that mentions that</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>An accepted packet is eligible to be modified by the additional parameters configured in the action portion of the policy configuration.</p>
</blockquote>



<p>I would guess, however, that this is too &#8220;low level&#8221; an operation for the sort of functionality we&#8217;re talking about, and there is likely some kind of appliance dedicated to intercepting and modifying specifically HTTP traffic without worrying about modifying and reassembling individual packets.</p>



<p>But it seems equally plausible that it is just software running on the modem or router itself, which could periodically &#8220;phone home&#8221; to the ISP to check whether there are any &#8220;user messaging&#8221; campaign the ISP wants to run. </p>



<p>Unfortunately there probably are no ISPs (maybe Google Fiber?) whom you could trust to not engage in this sort of shady activity. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2023/12/09/optimum-isp-is-mitming-its-customers/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>

		<media:content url="https://lukerodgers.ca/wp-content/uploads/2023/12/screenshot-2023-12-09-at-7.10.05-am.png?w=1024" medium="image" />
	</item>
		<item>
		<title>Type punning, strict aliasing, and BSD sockets</title>
		<link>https://lukerodgers.ca/2023/10/07/type-punning-strict-aliasing-and-bsd-sockets-oh-my/</link>
					<comments>https://lukerodgers.ca/2023/10/07/type-punning-strict-aliasing-and-bsd-sockets-oh-my/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sat, 07 Oct 2023 20:54:44 +0000</pubDate>
				<category><![CDATA[confusing things]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://lukerodgers.ca/?p=992</guid>

					<description><![CDATA[Working through Robert Nystrom&#8217;s excellent Crafting Interpreters book, I came across something I hadn&#8217;t thought about for a long time, as someone who generally sticks to dynamic languages at work: type punning and strict aliasing. In Crafting Interpreters, this arises in the context of an optimization called NaN boxing that I won&#8217;t get into (though [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Working through Robert Nystrom&#8217;s excellent <a href="https://craftinginterpreters.com/"><em>Crafting Interpreters</em></a> book, I came across something I hadn&#8217;t thought about for a long time, as someone who generally sticks to dynamic languages at work: type punning and strict aliasing. </p>



<p>In <em>Crafting Interpreters</em>, this arises in the context of an optimization called NaN boxing that I won&#8217;t get into (though you can read more about it in the book <a href="https://craftinginterpreters.com/optimization.html#nan-boxing">here</a>, or <a href="https://softwareengineering.stackexchange.com/questions/185406/what-is-the-purpose-of-nan-boxing">what is the purpose of NaN boxing?</a>), but basically the idea is:</p>



<ul class="wp-block-list">
<li>the basic <code>Value</code> type of the Lox language from the book takes up 16 bytes: 8 bytes for the largest possible values (doubles and <code>Obj</code> pointers), plus 4 bytes for the type tag (since a dynamic language needs to keep track of this at runtime), and 4 bytes of padding.</li>



<li>can we make this smaller somehow?</li>



<li>well certain IEEE 754 NaN layouts have a bunch of unused bits, maybe we can use those, since a IEEE 754 float is also 64 bits, enough for floats and pointers, and since most 64-bit architectures actually only use 48 bits for a pointer, we still have 16 bits to store type information.</li>
</ul>



<p>To do this, we&#8217;ll need to convince the C compiler (since this particular Lox implementation is written in C) to treat this 64 bit value as variously a <code>float</code> or <code>uint64_t</code>, and this is the essence of <em>type punning</em>. </p>



<p>However, in a side note Nystrom mentions</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Spec authors don’t like type punning because it makes optimization harder. A key optimization technique is reordering instructions to fill the CPU’s execution pipelines. A compiler can reorder code only when doing so doesn’t have a user-visible effect, obviously.</p>



<p>Pointers make that harder. If two pointers point to the same value, then a write through one and a read through the other cannot be reordered. But what about two pointers of <em>different</em> types? If those could point to the same object, then basically <em>any</em> two pointers could be aliases to the same value. That drastically limits the amount of code the compiler is free to rearrange.</p>



<p>To avoid that, compilers want to assume <strong>strict aliasing</strong>—pointers of incompatible types cannot point to the same value. Type punning, by nature, breaks that assumption.</p>
<cite><a href="https://craftinginterpreters.com/optimization.html#numbers">https://craftinginterpreters.com/optimization.html#numbers</a></cite></blockquote>



<p>Unstated here is that &#8220;cannot point to the same value&#8221; means that if they do, this will invoke dreaded undefined behaviour (there are many thorough references to UB, see <a href="https://blog.regehr.org/archives/213">John Regehr&#8217;s Guide to undefined behaviour in C and C++</a> for a particularly good one, also <a href="https://www.youtube.com/watch?v=yG1OZ69H_-o">Garbage In, Garbage Out: Arguing about UB</a> (youtube presentation), and also <a href="https://predr.ag/blog/falsehoods-programmers-believe-about-undefined-behavior/">Falsehoods Programmers Believe about UB</a>). </p>



<p>This reminded me of having worked through the classic <a href="https://beej.us/guide/bgnet/">Beej&#8217;s Guide to Network Programming</a>, which I still think is a great (if perhaps outdated) intro to sockets and programming in C. (It was also the basis for my attempt to write a <a href="https://github.com/lukeasrodgers/fortran-server">basic tcp server in Fortran</a>). An essential element of the magic of BSD sockets you are introduced to in that guide is <a href="https://beej.us/guide/bgnet/html/split/ip-addresses-structs-and-data-munging.html#ip-addresses-structs-and-data-munging">the <code>addrinfo</code> struct</a>, which looks like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
struct addrinfo {
    int              ai_flags;     // AI_PASSIVE, AI_CANONNAME, etc.
    int              ai_family;    // AF_INET, AF_INET6, AF_UNSPEC
    int              ai_socktype;  // SOCK_STREAM, SOCK_DGRAM
    int              ai_protocol;  // use 0 for "any"
    size_t           ai_addrlen;   // size of ai_addr in bytes
    struct sockaddr *ai_addr;      // struct sockaddr_in or _in6
    char            *ai_canonname; // full canonical hostname

    struct addrinfo *ai_next;      // linked list, next node
};
</pre></div>


<p>Note that the <code>ai_addr</code> pointer to <code>struct sockaddr</code> is said to be either <code>sockaddr_in</code> or <code>sockaddr_in6</code> &#8211; this allows the code to work with either ipv4 or ipv6. </p>



<p>When we are setting up a server to listen on a port, we first need to call <code>bind</code> and pass it, among other things, a pointer to a <code>struct sockaddr</code> – but we&#8217;ll actually have either a <code>sockaddr_in</code> for ipv4 or <code>sockaddr_in6</code> for ipv6, which will have to be cast first to a generic <code>sockaddr</code>. </p>



<p>Beej notes that the &#8220;old&#8221; way (maybe this is what the guide had when I first went through it?) was like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: cpp; title: ; notranslate">
bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr);
</pre></div>


<p>But this seems to violate the rule of strict aliasing outlined above: we now have two pointers to the same memory of different types, one is a <code>struct sockaddr_in</code> (assuming we&#8217;re using ipv4) and the one passed to <code>bind</code> is a cast to a <code>struct sockaddr</code>. How is this not introducing undefined behaviour?</p>



<h3 class="wp-block-heading">Am I alone in my confusion?</h3>



<p>Turns out some other folks on the internet had the same questions:</p>



<ul class="wp-block-list">
<li><a href="https://stackoverflow.com/questions/17988496/berkley-sockets-breaking-aliasing-rules">Berkeley sockets, breaking aliasing rules?</a></li>



<li><a href="https://www.reddit.com/r/cpp/comments/owq1q4/am_i_crazy_or_is_it_impossible_to_work_with_bsd/">Am I crazy or is it impossible to work with BSD sockets in C++ without UB?</a></li>



<li><a href="https://stackoverflow.com/questions/1429645/how-to-cast-sockaddr-storage-and-avoid-breaking-strict-aliasing-rules">How to cast sockaddr_storage and avoid breaking strict-aliasing rules</a> (this one specifically mention&#8217;s Beej&#8217;s guide)</li>
</ul>



<p>One Stack Overflow response states:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>The cast itself in that line does not break the strict aliasing rule. The rule is only broken if the implementation of <code>bind()</code> dereferences that pointer without converting it back to the right type.</p>



<p>Any strict aliasing problems there are problems for the implementer of <code>bind()</code>, not the user.</p>
<cite><a href="https://stackoverflow.com/a/17988634" rel="nofollow">https://stackoverflow.com/a/17988634</a></cite></blockquote>



<p>So this means perhaps <em>our</em> code isn&#8217;t causing UB, but the <code>bind</code> implementation itself may be? (<a href="https://github.com/torvalds/linux/blob/master/net/ipv4/af_inet.c#L472-L488">Looking at <code>__inet_bind</code></a>, which seems to be what ultimately does the heavy lifting for ipv4 sockets, the code is definitely dereferencing and reading from the pointer.) That still seems like a very undesirable situation.</p>



<p>Responses to the reddit post above (&#8220;Am I crazy&#8230;&#8221;) echo a similar idea:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>And bind() gets a free pass for either one of two reasons: it&#8217;s written in C and thus is only bound by the rules of C, and/or it&#8217;s provided by your implementation, and those don&#8217;t have to abide by the same rules as us mere mortals.</p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>If *you* try to read or write it through the aliased type, yes, it is UB.</p>



<p>Fortunately, you&#8217;re not, <code>bind()</code> is a black box to the compiler.</p>
</blockquote>



<p>I didn&#8217;t find either of these responses entirely satisfying.</p>



<ul class="wp-block-list">
<li>Just because <code>bind</code> is a syscall provided by the kernel doesn&#8217;t seem like it should mean it is exempt from C&#8217;s aliasing rules.</li>



<li>Again, even though <code>bind</code> is in this case a &#8220;black box&#8221; to the compiler, are we to just trust that the compiled <code>bind</code> code will not be subject to UB? </li>
</ul>



<p>But it turns out that there is some truth to these responses, as per this <a href="https://www.yodaiken.com/2018/06/07/torvalds-on-aliasing/">rant from Linus on aliasing</a>, in which he says the kernel uses the GCC flag <code>-fno-strict-aliasing</code> precisely to avoid issues like this. (Of course, &#8220;us mere mortals&#8221; are free to use this flag too.)</p>



<p>Linus also comes out strongly in support of using C unions to do type punning, which has apparently been the approved way to do this sort of thing in GCC for some time.</p>



<p>So does this mean that it is not possible to write <code>bind</code> (and likely related kernel networking code) without using potentially-standard-violating compiler extensions? It seems like the answer would have been &#8220;yes&#8221;, prior to the C99 and C11 standards, which added official support for type punning through unions (<a href="https://stackoverflow.com/a/11640603">though there appears to still be disagreement by some over how official the support is</a>).</p>



<h2 class="wp-block-heading">Additional reading</h2>



<ul class="wp-block-list">
<li><a href="https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8">What is the strict aliasing rule and why do we care?</a></li>



<li><a href="https://blog.regehr.org/archives/959">Type punning, strict aliasing, and optimization</a></li>
</ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2023/10/07/type-punning-strict-aliasing-and-bsd-sockets-oh-my/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>Paying down technical debt won&#8217;t necessarily increase your velocity</title>
		<link>https://lukerodgers.ca/2023/07/02/paying-down-technical-debt-wont-necessarily-increase-your-velocity/</link>
					<comments>https://lukerodgers.ca/2023/07/02/paying-down-technical-debt-wont-necessarily-increase-your-velocity/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Sun, 02 Jul 2023 14:33:07 +0000</pubDate>
				<category><![CDATA[web and tech]]></category>
		<guid isPermaLink="false">http://www.lukerodgers.ca/?p=966</guid>

					<description><![CDATA[(This piece is a work in progress, a placeholder for developing thoughts on technical debt and measuring the performance of software development teams. I will update it as my opinions change.) An oft-cited benefit of paying down technical debt is that it will allow you to move faster. This is typically characterized in terms of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>(This piece is a work in progress, a placeholder for developing thoughts on technical debt and measuring the performance of software development teams. I will update it as my opinions change.)</p>
<p>An oft-cited benefit of paying down <a href="https://martinfowler.com/bliki/TechnicalDebtQuadrant.html">technical debt</a> is that it will allow you to move faster. This is typically characterized in terms of increased velocity.</p>
<p>But if you are measuring velocity by factoring in &#8220;accidental complexity&#8221;, then when you remove the source of that accidental complexity, your velocity will not actually appear to improve. This point is well put by <a href="https://software.rajivprab.com/2023/07/01/moneyball-for-software-teams/">Moneyball for software teams: an imperfect heuristic for quantifying dev performance</a>. This runs contrary to what we&#8217;d generally expect from a measure of developer velocity, and also contrary to the business case that is usually made for paying down technical debt: to simplify, reduced debt = increased velocity.</p>
<p>The aforementioned article presents a reasonable way out of the impasse of a) needing to factor tech debt into your estimates, b) wanting tech debt reductions to be visible as increased velocity i.e. more &#8220;story points&#8221; per cycle. (Whether it is necessary or desirable to adopt this approach is debatable, and personally I&#8217;d still bias towards avoiding measurement of velocity at all, and having developers do PERT estimates only as necessary. This seems to be less common outside small, high trust teams.)</p>
<p>But even if you are measuring velocity this way, it is entirely possible that you could pay down all the tech debt and still <em>not</em> have your velocity  (as a measurement of essential complexity) increase:</p>
<ul>
<li>new sources of accidental complexity can emerge that are not at all under your control, whether from vendors, dependencies that are suddenly EOLd or have hard to patch security flaws, and so on</li>
<li>eliminating a given set of sources of accidental complexity may enable your team to take on other types of projects that are subject to additional kinds of accidental complexity. These new tasks or projects may have higher business value, but that won&#8217;t be reflected on your velocity (or probably reflected anywhere because <a href="https://martinfowler.com/bliki/CannotMeasureProductivity.html">We can&#8217;t measure developer productivity</a>). This is reminiscent of the way in which improving tail latency can actually cause median latency to increase: previously, requests from slow clients would time out or never be initiated in the first place, but after improving performance for those clients, their requests will now succeed, albeit at latencies greater than your current median.</li>
<li>even if your velocity does go up, will the signal be strong enough to be distinguishable from statistical noise (maybe one of your senior developers finally got their kid into an after school program and now they are back to &#8220;full performance&#8221; level)? do you have tools sophisticated enough to discern this?</li>
</ul>
<p>Returning to the moneyball comparison from above: sport performance is generally easily and unambiguously measurable (did the ball go in the net?), and what it means to do well can be reduced to &#8220;win competitions&#8221;. Software development is inherently harder to measure, and has many axes along which something can be called &#8220;a success&#8221;. Moreover, whether a software project turns out to have been successful may not be discernible for months or years down the road, for reasons business or market reasons that have nothing to do with the development project &#8220;in itself&#8221;. For these reasons, it is at best a waste of time, if not actively harmful, to foist such methods into software management.</p>
<p>That said, my thoughts on this topic are always challenged by the ideas of Hubbard (e.g. <a href="https://hubbardresearch.com/publications/how-to-measure-anything-book/">How to Measure Anything</a>) whose main argument boils down to, if it matters you can notice it, and if you can notice it, you can (at least sort of) measure it.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2023/07/02/paying-down-technical-debt-wont-necessarily-increase-your-velocity/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>Is &#8220;success mostly results from luck and connections&#8221; a luxury belief?</title>
		<link>https://lukerodgers.ca/2023/03/07/is-success-mostly-results-from-luck-and-connections-a-luxury-belief/</link>
					<comments>https://lukerodgers.ca/2023/03/07/is-success-mostly-results-from-luck-and-connections-a-luxury-belief/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 04:06:38 +0000</pubDate>
				<category><![CDATA[philosophy]]></category>
		<category><![CDATA[things about which I am ambivalent]]></category>
		<guid isPermaLink="false">http://www.lukerodgers.ca/?p=961</guid>

					<description><![CDATA[I have been pondering this essay from Rob Henderson for a while, and will continue to do so: Luxury Beliefs are Status Symbols. Much of it is well-argued and compelling. I need to consider it further before I can say how much I agree or disagree. But one part is so poorly argued it merits [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I have been pondering this essay from Rob Henderson for a while, and will continue to do so: <a href="https://robkhenderson.substack.com/p/status-symbols-and-the-struggle-for">Luxury Beliefs are Status Symbols</a>.</p>
<p>Much of it is well-argued and compelling. I need to consider it further before I can say how much I agree or disagree.</p>
<p>But one part is so poorly argued it merits mentioning. Henderson writes:</p>
<blockquote><p>There are other examples of luxury beliefs as well, such as the downplaying of individual agency in shaping life outcomes.</p>
<p>A 2019 study led by Joseph Daniels at Marquette University was published in the journal of Applied Economics Letters.</p>
<p>They found that individuals with higher income or a higher social status were the most likely to say that success results from luck and connections rather than hard work, while low-income individuals were more likely to say success comes from hard work and individual effort.</p>
<p>Well, which belief is more likely to be true?</p>
<p>Plenty of research indicates that compared with an external locus of control, an internal locus of control is associated with better academic, economic, health, and relationship outcomes. Believing you are responsible for your life’s direction rather than external forces appears to be beneficial.</p>
<p>Here’s the late Stanford psychology professor Albert Bandura. His vast body of research showed that belief in personal agency, or what he described as “self-efficacy,” has powerful positive effects on life outcomes.</p>
<p>Undermining self-efficacy will have little effect on the rich and educated, but will have pronounced effects for the less fortunate.</p></blockquote>
<p>According to Henderson this is evidence that this belief is a &#8220;luxury belief&#8221;.  I have a few problems with this section</p>
<p><strong>1. The framing</strong></p>
<p>Henderson asks &#8220;which belief is more likely to be true?&#8221; and then goes on to discuss the <em>benefits</em> of believing one vs the other, which patently has nothing to do with a belief being true. Was this just bad editing? This is such a non sequitur, I don&#8217;t know what to make of it.</p>
<p>There is plenty of research (though what I was able to find in a brief internet search generally seemed low quality) on whether hard work vs luck vs other factors are contributors to success. Henderson does not consider any of that here.</p>
<p>Additionally, there is a large body of research, as Henderson states, on the benefits of internal locus of control (e.g. <a href="https://pubmed.ncbi.nlm.nih.gov/9747186/">The happy personality</a>) and it does support the idea that internal locus of control is correlated with happiness and achievement. But it seems like a bit of a jump to go from &#8220;people emphasize the important of luck and connections in having success&#8221; to &#8220;people have weak/less internal locus of control and therefore are more likely to be unhappy and achieve less&#8221;, which is the conclusion that Henderson implies. The data used in the paper under discussion come from the World Values Survey, specifically the questions here are:</p>
<blockquote><p>An answer of “in the long run, hard work usually brings a better life’ carries a value of one (1) in the survey and an answer of ‘hard work doesn’t generally bring success – it’s<br />
more a matter of luck and connections’ carries a value<br />
of ten (10).</p></blockquote>
<p>To me this seems more about achieving societal markers of success (income, savings, housing, cars), while internal vs external locus of control is more about an individual believing they are responsible for and in control of what they do.</p>
<p>I am obviously not an expert on these terms, nor deeply familiar with the relevant theory and research, so I may be wrong here, but it seems like a big analytical leap that Henderson is making here. The relevance of this research to Henderson&#8217;s claim needs to be <em>argued</em> but he assumes it is obvious and uncontroversial.</p>
<p><strong>2. The research</strong></p>
<p>Reading the original research paper, we see the following correlations between belief in luck/connections (there are some others as well, but these are the ones that stand out as most problematic for Henderson&#8217;s case, in my opinion):</p>
<ul>
<li>with social class: 0.0834</li>
<li>with gender: 0.0678</li>
<li>with country&#8217;s GDP: 0.0844</li>
<li>with income: 0.0077</li>
</ul>
<p>Henderson seems to latch onto the correlation with social class, but this  leaves us with a few head scratchers, given his conclusions:</p>
<ul>
<li>if this is a luxury belief, why is the correlation with income so much weaker than the correlation with social class?</li>
<li>why is there a correlation with GDP? are entire populations of wealthier countries more likely to adopt this view in order to distinguish themselves from other countries?</li>
<li>what&#8217;s with women? why are they so more drawn to this luxury belief than men?</li>
</ul>
<p>It seems like Henderson had an idea, went around looking for evidence, found something resembling evidence if you squint right and ignore some things, and then just ran with it.</p>
<p>I understand that the piece of writing I&#8217;m discussing is not academic per se, but given that he frames it as a transcript of a talk he delivered at a &#8220;behavioural science festival&#8221; I found the lack of rigor in this part disappointing. It casts a shadow over the rest of the argument.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2023/03/07/is-success-mostly-results-from-luck-and-connections-a-luxury-belief/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing a Boss 560BRGB stereo in a 2012 Mazda 5</title>
		<link>https://lukerodgers.ca/2023/03/07/installing-a-boss-560brgb-stereo-in-a-2012-mazda-5/</link>
					<comments>https://lukerodgers.ca/2023/03/07/installing-a-boss-560brgb-stereo-in-a-2012-mazda-5/#respond</comments>
		
		<dc:creator><![CDATA[lukeasrodgers]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 03:30:29 +0000</pubDate>
				<category><![CDATA[building making fixing]]></category>
		<guid isPermaLink="false">http://www.lukerodgers.ca/?p=956</guid>

					<description><![CDATA[I purchased this Boss 560BRBG aftermarket stereo from Crutchfield for my 2012 Mazda 5. Installation and setup was pretty smooth, facilitated by Crutchfield&#8217;s support documentation which really surpassed my expectations. If you&#8217;re looking to tackle a project like this I recommend buying from them vs Amazon. But a few things were still tricky or non-obvious, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I purchased this <a href="https://www.crutchfield.com/p_104560BRGB/Boss-560BRGB.html?omnews=18196190">Boss 560BRBG aftermarket stereo from Crutchfield</a> for my 2012 Mazda 5. Installation and setup was pretty smooth, facilitated by Crutchfield&#8217;s support documentation which really surpassed my expectations. If you&#8217;re looking to tackle a project like this I recommend buying from them vs Amazon. But a few things were still tricky or non-obvious, so I&#8217;m going to share some of them here in case others struggle with some of the things I did.</p>
<p>To be honest, if I had noticed the <a href="https://www.crutchfield.com/S-qCoGVpI5KZy/car/wireguide/wireguide.aspx?orderstatusid=03886A9D-4D45-49C3-BCA9-CFC5AECFEFA2&amp;invno=32492041&amp;receiveritemindex=1">handy wiring guide</a> Crutchfield mentioned in my purchase email, I probably wouldn&#8217;t have had several of these difficulties, but I somehow missed it until just now.</p>
<p><strong>First of all, you are going to have to solder some wires</strong></p>
<p>If you&#8217;ve ever done a project like this, that fact is probably obvious, but I naively assumed that the Crux SWRMZ-64C Wiring Interface that came with my package would mean the whole thing was just plug n play. I got all the dashboard panels popped off and the old radio removed before I realized this, then ran out of time and had to put everything back together and wait until the next weekend when I had time to tackle the soldering.</p>
<p>Fortunately I had recently acquired a soldering gun and been getting some practice. You could maybe use crimp connectors or some other method instead of soldering, but the soldering was not that difficult, provides a better connection, and is more fun.</p>
<p><strong>Removing the panels to get at the guts</strong></p>
<p>This part was actually kind of interesting, turns out most of the panels on your car just pop off with the help of some trim panel tools and a philips head screwdriver. Again, something that is probably obvious to many folks.</p>
<p>One bit of advice I got from somewhere on the internet for this step was: after you&#8217;ve unscrewed the gear shift nob and popped off the gear shift trim panel, you can press down a little white lever with your finger or screwdriver to shift the car into neutral, which makes it easier to remove the climate control assembly. You could probably just do this at the outset. Obviously make sure your parking break is on.</p>
<p><strong>Soldering the stereo wires to the wiring interface</strong></p>
<p>Basically you can just follow the wiring guide from Crutchfield here, and match similarly-colored wires to each other. However</p>
<ol>
<li>The manufacturer&#8217;s manual that comes with the wiring interface <a href="https://www.crutchfield.com/p_249MZ64C/Crux-SWRMZ-64C-Wiring-Interface.html?omnews=18196190#&amp;gid=1&amp;pid=4">incorrectly identifies</a> one of the wires as blue, when it is actually (in my case) brown. This is the Steering Wheel Control (SWC) Phone wire, which won&#8217;t be used for anything if you have the same year/model Mazda and this stereo. I soldered it to the brown wire on the stereo which turned out to be unnecessary, but not actively harmful.</li>
<li>The blue wire of the power antennae is similarly useless for this car, as the antennae doesn&#8217;t require power. You can just plug the antennae jack into the back of the radio, and top the blue wire off with electrical tape. Easy.</li>
<li>Because Steering Wheel Controls are simply incompatible with this stereo, flipping the dip switches on the interface module is unnecessary. Additionally, connecting the two wires that come out the other side of this module is also unnecessary, you can just toss those away, or keep them in your electronic junk box forever until you die because you will never use them for anything so just throw them away.</li>
<li>There will be an extra module just hanging out that connected to your old stereo, but has nowhere to go with the new one. I&#8217;m not sure what this is for, possibly SWC, but either way you can just ignore it and leave it hanging around. This little white guy here, no home for you any more buddy. <img data-attachment-id="957" data-permalink="https://lukerodgers.ca/2023/03/07/installing-a-boss-560brgb-stereo-in-a-2012-mazda-5/2023-03-05-11-35-35/" data-orig-file="https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg" data-orig-size="800,600" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;1.6&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 12 mini&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1678016134&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.2&quot;,&quot;iso&quot;:&quot;100&quot;,&quot;shutter_speed&quot;:&quot;0.0082644628099174&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="2023-03-05 11.35.35" data-image-description="" data-image-caption="" data-medium-file="https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg?w=300" data-large-file="https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg?w=800" tabindex="0" role="button" class="alignnone size-full wp-image-957" src="https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg" alt="" width="800" height="600" srcset="https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg 800w, https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg?w=150&amp;h=113 150w, https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg?w=300&amp;h=225 300w, https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg?w=768&amp;h=576 768w" sizes="(max-width: 800px) 100vw, 800px" /></li>
</ol>
<p><strong>Mounting the stereo<br />
</strong></p>
<p>I mostly ignored the mounting instructions that came with the stereo itself as they were confusing and seemingly incompatible with the Metra 99-7521B Dash Kit that was part of the package, and necessary to ensure you don&#8217;t have a gaping hole remaining in your dashboard.</p>
<p>I don&#8217;t have any good advice for this part, other than &#8220;just do what seems like it will work, ensuring that the unit is securely attached, without putting undue stress on the wires&#8221;.</p>
<p>Hearing this thing actually play a CD was probably the most satisfying feeling of accomplishment I&#8217;ve had in years.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lukerodgers.ca/2023/03/07/installing-a-boss-560brgb-stereo-in-a-2012-mazda-5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://1.gravatar.com/avatar/d4fb2446082a720a6f80c08d37732bb61b5d11ae3507f03a1c5f1a1c5ed249be?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lukeasrodgers</media:title>
		</media:content>

		<media:content url="https://lukerodgers.ca/wp-content/uploads/2023/10/b9780-2023-03-05-11.35.35.jpg" medium="image" />
	</item>
	</channel>
</rss>
