Optimization

Tonight it hit me, as I was giving advice, that I was dispensing wisdom I would do well to listen to myself. It was a question about optimization. Whenever you use that word, you have to know what you are optimizing for. Sometimes I forget.

One of the approximations of social media I engage in is a place called StackOverflow.com. That site and dozens of its sisters are an indispensable resource for programmers and tech folk in general. Some nights, like tonight, when I’m a little adrift, I will stop by over there and see if there are any questions pending I am qualified to answer.

When you’ve been around a while, you realize that there are almost no new questions, and in the major categories there are semi-pro question-answerers who can swiftly point the new question to the ancient answer. For php, you will see the name Barmar time and again, always helpful, always gentle.

But there is a category of question that in general is found to be annoying on Stack Overflow, but that I can answer well. These are questions that go beyond the nuts-and-bolts of a language to get to the heart of what programming really is. I will see the code they post, often a mess, and I can sort through it and figure out what is the actual question.

While others will downvote the question for being a mess, I find an opportunity to teach. I see someone who, with a little help, will see the mess also. My answers are long, and meticulous, but if I feel like I’m answering a homework question I leave out the key stones in the path.

A recent example: Someone had code that took the result of a database query and built an html table. But the result of the query didn’t directly match what was to go into the table. So while drawing the table, the code was also trying to figure shit out.

I suggested that while there was no way I was going to figure out what was wrong with the code as written, I had a simple concept to apply: Think, then Draw. Get all the information set up beforehand so that creating the html was just a brain-dead loop.

I have discovered that I have axioms. One is “Keep the guards close to the gate.” Another, apparently, is “Think, then draw.”

Tonight I came across a question asking for how to optimize a data manipulation operation. Massive data in, then a rearrangement of the data to be more useful later. The code to accomplish the data transform included nested loops, but was pretty tight and pretty clean. “How do I optimize this?” was the question.

I have come to realize that optimization of code is an economic judgement, not a technical one. The most obvious tradeoff: You can use more memory to make your process run faster.

But there is another, more subtle, economic tradeoff. Tonight I answered the optimization question with another economic argument: that Engineer Hours are worth more then CPU milliseconds. I told that person that if their code worked, and there wasn’t a specific problem caused by it, then it was perfect and they should move on to the next problem. I told that programmer to value their own time. Not just for personal reasons, but to better judge how their time could best help their endeavor.

Value your time, but also recognize the cost of your time.

My friends, this is something I do not do well. Where I work, I am moving our stuff from an environment where it was hosted for free, to a place where we will have to pay for the resources. I am, at heart, a cheap bastard. While that does me well at the poker table, it may not always serve the interests of my employer. I am constantly aware that all resources I request will now be billed.

So I spend time, hours of my time, trying to guess how small a footprint I can squeeze into on behalf of our group. I spend hours on elaborate schemes to do more with less. But I am not serving my clients well. I’m not including the cost of my time in the value equation. Things are too slow? I could spend a week doing clever stuff, at a cost to my company of thousands of dollars in my compensation while I defer projects that actually will make things run better, or I could just submit a form and get more RAM for the database, at an incremental cost for the department each month.

In my defense, I HATE filling out forms. I HATE the call that comes after while someone else re-enters the form into a different system, and invariably makes a mistake. I will take a week with the code over an afternoon of nonsense any time. But that is a weakness, not a strength. That is me allowing my own preferences to make decisions that are not properly optimized.

I am, at heart, a person who can take a problem and slice it and slice it and slice it until each part is a simple question, and I can take the answers to those questions and combine them to arrive at the solution. While I’m at it, I’ll make tests so that each part proves itself. When you see my code at the flea market, it will be on the shelf behind the table, where you will have to ask to get a closer look. I am proud of this. But it is not always a good thing.

There was a time I was VP of Software Engineering at a small company, and I did all right in that role. During the dot-com boom I held a pretty dang good team together. I didn’t have to fill out forms then, either. We were all just building something awesome. The calculus of the value of my time was different then; Engineer-hours — my hours — were a commodity; the value only to be realized if the venture succeeded. (Picture Facebook, before Facebook, only far more dynamic, with the fatal flaw of being private.)

Good times, good times. The sleep-optional days of youth. But if I’m going to justify that little walk in the past in this ramble, I have to tie it to the present.

Back then, I was paid well enough but there was never doubt that Engineer Hours were the currency we were paying to make our name. Our data center was a few racks in a room that had once been a bank vault (AWS was decades away yet). Everything, everything, was optimized for minimum CPU.

Tonight, while I was (very gracefully I’m sure) reminding a young coder about the relative value of CPU cycles relative to neuron flashes, I realized that I have not been very good at making that judgement myself. I need to do better. Not just for my team, but for myself. I need to fill out the goddam form, bluster my way to 4x the resources I actually think we need (magnificently tiny, in the scale of my company), and recognize that my time is better spent making new things, rather than helping the old things go.

4

The Bitcoin Plunge is not a Market Correction

It drives me batty to read respected people in national publications talk about the nosedive of Bitcoin and other crypto as a “market correction.”

A market correction happens when the price of a security or a general market of securities overruns any sort of historical baseline for value. When you talk about stocks, there are the simple metrics of how much money a company makes or the value of that company’s assets. There are metrics like that for real estate, municipal bonds, and even manufacturing.

A correction comes when the market realizes that the price has been bid up far past what the underlying value of the asset is. This happens fairly often: people buy stock based on what they expect the performance of the company to be. Sometimes people get excited.

When people say that crypto is no different than the stock market, they are either lying to you or to themselves. There is no P/E report on Bitcoin. No debt-to-asset report on Etherium. Because there is nothing there. There is nothing, absolutely nothing, supporting the value of those tokens.

The price is based on blind faith, sell-shaming, and billionaires spinning a story that ends with them having your money.

The tower is crumbling now; we have been on a roughly monthly cadence hearing about the failure of some sham company that banked everything on crypto always going up. The market plunges, then holds steady for a while, cryptobros in their executive suites sweating as the scam crumbles until they rush for the doors calling back over their shoulders “#HODL!” and another crypto company based on the “always-up” model craters, unable to even tolerate the market that is merely steady.

A true market correction would reduce Bitcoin to just a little bit over zero. I will grant the little bit because Bitcoin is just a little bit useful for things besides being a store of value. Oligarchs have to shift their cash, after all.

6

Hot Times in the City

The temperature went over one hundred degrees here today, as it does sometimes (more often lately, but we all know that). At about 2pm the guys who messed up our ducts came back and fixed out ducts, and life was good — the best cooling this house has ever known. Until about 4pm. That’s when the AC shut down entirely. Hopefully it’s just a matter of replacing (again) the ridiculously huge fuses on the unit. (Although huge fuses mean huge power and BLOWING huge fuses means maybe it’s time to replace the damn thing.)

It’s warm in here right now. Warm enough that my laptop, already prone to run hotter than one would think necessary, essentially shut itself down to prevent it from burning itself up.

My laptop is a MacBook, and they are not generally considered good gaming machines for two reasons: one, the hottest games don’t run on Macs, and two, because Macs aren’t built to dissipate the heat that comes with the massive processing in a modern computer game.

But today I wasn’t running any graphic-intensive game. I did play NetHack for a while, but that is the opposite of graphics-intensive. And because I was playing on NAO, even that processing was happening in a data center somewhere (or perhaps, a linux box under someone’s desk).

MacBooks, when overheating, use a process to simply block out all other programs part of the time, to reduce the load so the computer can cool down. I reached a point today where the safety program was taking up all the time.

I quit any program that was even using the slightest CPU and the situation did not improve. I shut down the machine, waited a few minutes, and started it back up to the slowest reboot since DOS was on floppies, because the kernel task went straight to maximum protection.

Finally, I went to the freezer and pulled out a cold pack I use on my knee. I put the computer to sleep, and set the thing right onto the cold pack, and when I woke it up the machine was happy. For a little while, at least.

I have now used a second cold pack, which is why I’m able to write this right now.

If you search for “Refrigerated Laptop Cooling Pad” or any of a hundred permutations, you will get lots of hits, but none of them are actually refrigerated. They just have lots of fans. And while I’m sure that helps, I’m a little surprised that there’s no active cooling. The top-tier game machines have liquid cooling built directly into the enclosure. It doesn’t seem a stretch to extend the heat sink of a metal-hulled laptop with a refrigerated system to take the heat away.

I’m filing this episode under Get Poor Quick because this is such a golden opportunity for the right person. Get on that, right person! Make the Chill Spot. I’m tired of my laptop shutting itself down!

4

The Cult of Crypto

The price of Bitcoin is about 30% of what it was a few months ago. The other cryptocurrencies (note: they are not currencies) have been similarly battered. Crypto-based businesses are starting to fail. But if you read what the people still clinging to their vapor-money are saying, you will see #HODL, over and over again.

It is simply a typo for “hold”, that feels more insider-y. Like a secret handshake. The purpose of #HODL is simple: to prevent people from selling their crypto stakes. In itself, this could just be construed as financial advice. “This is a volatile asset, and if you panic you will lose.” And that’s good advice for all investors!

But #HODL and the community behind it use the phrase differently. Consider the company MicroStrategies. They have bought into Bitcoin in a big way, and are now using every resource they have to evangelize — to bring new, naïve money into the market. They know that the price of Bitcoin will only go up if they can convince more people to buy it.

Over the last couple of years, companies like MicroStrategies have succeeded in convincing the business press and the impatient segment of the investment population that Here be Riches.

Step 1: get the suckers to buy, to drive up the value of your holdings.

Step 2: prevent the suckers from selling even when it’s in their best interest to do so.

Consider kraken.com. They are a crypto exchange, meaning they make money when people sell or buy tokens through their service*. They recently declared, in the aftermath of the latest crypto price plunge (I’m paraphrasing): Bear markets weed out the weak. The strong will #HODL. We will also spend the money we take from you to lobby the government on behalf of our singular devotion to our mission, even if that means hurting others. And yay guns.” I cannot find articulated on their Web site what the mission is, but it must be important!

There is, from corporate communications right down to reddit, a culture of sell-shaming. The faithful shall come through adversity and inherit the wealth they deserve. Any so timid as to sell shall die in poverty and shame. This intimidation was necessary to keep the crypto bulge alive. In fact, the believers honestly thought that if they could keep people from selling, the price of their favorite crypto token would go up forever.

They believed, simply, that buying Bitcoin was buying into a sacred trust. That anyone who bought crypto was implicitly obligated to #HODL. For the common good.

But the buyers (I will not call them investors) those crypto-pushers needed to inflate the value of their coins diluted their cult. The new wave of buyers saw the historic rise of crypto, and didn’t understand their own role in causing it. But they weren’t part of #HODL; they bought at the worst time and sold at the worst time (until tomorrow), and broke the damn cult.

#HODL! #HODL! #HODL! the cultists cry as the crypto market spirals down. #HODL! These are the true believers, the ones who will #HODL into the ground, but I wonder how the ranks are holding up as airship Bitcoin plunges toward the 20,000 level after being at 69,000 a few months ago. How many people are crying #HODL as they strap on their own parachutes?

* One of the key features of cryptocurrencies is that theoretically there is no central authority. Yet almost everyone buys and sells their tokens through a trusted central exchange.

3

Facebook Project Canceled Due to Sadness (and Facebook)

For a few days I was posting regularly on Facebook. Each night, I would look at the Gun Violence Archive, and then post on Facebook:

Days since a well regulated Militia mass shooting in the United States: 0

El Paso, Texas
Phoenix, Arizona

The typography of “well regulated Militia” is to mirror exactly the way it is written in the Second Amendment. The cities are the places that had a mass shooting that day.

Had I posted a similar message yesterday, it would have listed seven cities. The day before, five.

The definition of “mass shooting” is one I’ve seen here and there: at least four victims, not counting the shooter. This includes those injured, not just killed. Their suffering in many cases is only starting.

There was actually a day when there was not one dang mass shooting in the whole country! Now there’s something to celebrate! It was a Monday. Today, also a Monday, no mass shootings have been recorded so far. Let’s hear it for Mondays!

I thought I might keep it up for a while, to maybe make the whole thing harder to ignore, to maybe open eyes to just how ordinary a mass shooting is in this country. I imagined myself making a difference by showing what the Second Amendment is actually accomplishing.

But I stopped, after only a few days. Tabulating the activities of well regulated Militias is not something to do at bedtime. Not if you want to sleep. Also, it meant I had to be on Facebook, which is unpleasant in it own right.

As a side note, the number of notifications I get when I visit Facebook has dropped dramatically. I wonder if a bunch of people unfriended me because of those posts. I hope so, but I don’t know how to figure that out.

3