Chris X Edwards


Line Is Not an Emulator?

2016-03-31 10:09

Wow! I knew Microsoft was seriously getting its act together, but their latest move is the most impressive yet.

You can read the reports here and here and here, but the basic story is clear from just the headline.

Bash on Windows

Microsoft just announced that Linux non-graphical programs will now run on Windows. This of course includes the main interface to Linux, the Bash shell. It also means all the other Unix tools that Linux and Mac users take for granted. This is huge news.

Basically this is like Wine but in reverse. Wine, started in 1993(!), is a recreation of the functionality of Windows system calls for Linux. So when a C program calls a standard function, for example, fopen() to open a file, the OS, which actually manages files and memory and processes and such, answers the call. Obviously the Linux kernel and the Windows kernel do things differently and Wine is a way to translate what a program is expecting from Windows into proper Linux calls. But this thing they’re showing does the reverse. When a Linux program (like Bash but it applies to all) runs on Windows, apparently this new Microsoft thing converts what Linux programs expect into the system calls appropriate for a system managed by Windows.

Of course there are still questions like, why can’t the open source Bash just be ported properly to native Windows? This question implies the real question — are there fundamental deficiencies in the Windows kernel that make full Bash functionality difficult? But hey a reverse Wine for Windows is still a great thing and will no doubt be very useful and make Windows a much more plausible system to use.

And if that’s not enough for one day, Microsoft is also releasing an extension to Visual Studio that allows C++ code to (cross?) compile for Linux machines. I’m guessing these things are related. Still, this is a pretty huge deal.

At this point if Microsoft releases a DirectX library for Linux (go ahead and charge for it, it’s good stuff), then Linux and Microsoft are suddenly on the same team. This is a great victory for Microsoft and an even greater one for Linux.

UPDATE: Here’s even more on this confirming my conjectures about what exactly this new feature is. It also mentions some of the things that don’t work which are related to the deficiencies in Windows I mentioned. Still, it will be very interesting to see how this develops.

The Right Tool For The Job - SQLight

2016-03-22 06:51

I created this almost exactly five years ago for a presentation where I was trying to explain why a MySQL database might be overkill.


I still think it’s quite helpful since several times a year I encounter someone who is using the wrong approach to manage their data. The situation that really puzzles me are the people who fret about what kind of SQL database engine they need to store files. I’ve lost track of the number of times I’ve said something like, "Why not put your files in a database designed especially for files? It’s called a file system."

Location, Location, Location, And Center of Mass

2016-03-17 16:40

When I read this neat little puzzle I was reminded of one of my more memorable experiences studying industrial engineering in college. We were supposed to be learning about location optimizing. Imagine you are a service technician and your work is done in the different facilities of your only three customers. The following table indicates where each facility is (X and Y) and how many times a year you have to visit it (N).

















The question is what would the optimal location be to establish your own headquarters in order to minimize driving?

In my class the following was proposed as the solution to this problem.

X= (n1x1 + n2x2 + n3x3) / (n1+n2+n3)
Y= (n1y1 + n2y2 + n3y3) / (n1+n2+n3)

Not only did I recognize that this was actually a center of mass calculation, but I had a nagging intuition that it was also incorrect when applied to this problem.

Here is the calculation for the center of mass of this system.

Xcom= (47*150 + 12*250 + 36*50) / (47+12+36) = 124.7368
Ycom= (47*50 + 12*250 + 36*150) / (47+12+36) = 113.1579
Center of mass = 124.7368,113.1579

The red point shows what that looks like.

(0,300) (300,0) (0,0) (50,150) n3=36 (250,250) n2=12 (150,50) n1=47

That looks reasonable. But is it right? In the class I was told that was the optimal position which implies a falsifiable hypothesis: you can not find another point that is better. For some reason, I thought I could.

To figure this out we must know what the total annual driving distance would be for the proposed center of mass location. First calculate the distance from the proposed point to each customer location.

d1= 68.0232
d2= 185.517
d3= 83.3242

You can check this kind of thing with a term such as distance {124.7368,113.1579} {50,150} in WolframAlpha.

Now multiply each distance by the number of trips to that location (e.g. T1= 68.0232 * 47).

T1= 3197
T2= 2226
T3= 3000

Add these together and the total distance traveled to service all of the customers for the year is 8423. Is it possible to choose a location that can yield a lower amount of annual driving?

What about (137,75)? Let’s do the same analysis for that point. First the distances from this point to all of the customers.

d1= 28.178
d2= 208.312
d3= 114.865

Now multiply that by the number of trips.

T1= 1324.366
T2= 2498.544
T3= 4135.14

The total distance for all of those trips from this point is 7958, more than a 5% improvement. This point is shown in green.

(0,300) (300,0) (0,0) (50,150) n3=36 (250,250) n2=12 (150,50) n1=47

Notice I’m not saying that (137,75) is optimal. I actually guessed to find this point. When I was in college I was able to write an AutoLisp program that iterated over the plausible area and just brute force checked for the best location. I did the same just now with my own geometry inspired Lisp-like programming language. I don’t actually know the best approach to solving this problem but it’s encouraging that I was able to notice that the official technique which I was taught was not it.

Woz Wisdom

2016-03-16 17:37

I’m a big fan of Steve Wozniak. I found his perspective on smartphones interesting. Answering the question, "Do you ever feel in your own life that it becomes overwhelming?"

I have that feeling all the time because I like a nice, quiet, simple life. I grew up shy. I’m more into products than I’m into socializing. And I do not carry around my phone answering every text message instantly. I am not one of those people.

I wait until I’m alone in my places and get on my computer and do things where I think I’m more efficient. I really see a lot of people that are dragged into it, but you know, I don’t criticize them. When you have change, it’s not that the change in how people are behaving different to you is bad or good, it’s just different.

So that’s sort of the modern way, and you know the millennials, every generation wants to criticize the next generation for missing out on things like personal human contact, but I’ll tell you a little story. When we started Apple, Steve Jobs and I talked about how we wanted to make blind people as equal and capable as sighted people, and you’d have to say we succeeded when you look at all the people walking down the sidewalk looking down at something in their hands and totally oblivious to everything around them!

I also felt this bit was noteworthy.

A focused student is someone who does all the right homework and gets all the right grades and they answer all the questions the same as somebody else that’s called smart, you know. And I don’t know, I always wanted to be in a different world, think differently. So I wasn’t all that focused.

Flash Describes How Long It Worked

2016-02-24 18:40

Yesterday I spent much of my day doggedly figuring out a reliable way to make bootable USB flash drives which contain not only Linux but a proper Linux file system too. For some demented reason the standard, even in the Linux community, for file systems on flash drives is right out of some kind of 1990s MSDOS nightmare. With these flash drives getting quite huge these days, this simply will not do. Especially since my concept is to stop booting from hard drives which are permanently attached to computers for my day to day work. I’ve actually been doing that for about 4 months including right now. The advantage of this is that you can boot to your favorite system on any hardware you come across. I’ve even used this trick to instantly and temporarily get my Linux on a MacBook. Since I wander all over a large university campus where I manage computers in at least a dozen different locations, this is appealing to me. I’m also interested in making very secure USB based installations for managing overly sensitive things like banking and AWS. This is Brian Krebs' recommended security strategy for such things.

Eventually I developed a reliable procedure using extlinux to boot a Linux from an ext2 partition on a flash drive. Of course I took complete notes on my research if you’re interested in that sort of thing. Once I felt that procedure was reliable I started installing Debian on a new 8GB flash drive. This seemed to go fine until it was in the middle of reading base packages which should take no more than a couple of minutes. The progress suddenly dropped by orders of magnitude. Very strange. I could see that something wasn’t right. I aborted that and did an rsync of a complete system onto the flash drive. This worked better and I was able to boot it and it all seemed ok.

It didn’t take long however before I started noticing some very odd performance quirks. Something was definitely going on with this drive. I had used it about 5 minutes when errors were reported which turned out to be that the drive no longer had the writable flag set. It had completely failed and was trying to let me get my data off it as its last desperate act.

$ sudo blockdev --report /dev/sdd
RO    RA   SSZ   BSZ   StartSec            Size   Device
ro   256   512  4096          0      8103395328   /dev/sdd

After reading the reviews of this product on Amazon I became even more intrigued. It seemed that most of the reviewers had no problem with this device but about 12% had big problems. Fortunately, or perhaps unfortunately, I had purchased a two pack and had a brand new clone of the dead one to experiment with.

I used Linux dd to do extensive testing of the reading and writing of characteristics of this drive. First let’s look at read performance. I did a "skip" to 30 equidistant points on the drive and had it read different amounts of data. The result I got with 64kB, 5MB, and 50MB reads was roughly the same as I got from the hdparm -Tt /dev/sdd command which showed a read throughput of between 18MB/s and 22MB/s. This was extremely consistent. At one third of the USB2.0 theoretical maximum, this drive reads fine. No problems.

Writing, however, was much more interesting. Using the same dd technique to "seek" to 30 equidistant points over the 8GB drive, I wrote varying amounts of random data.

Write Size

Write Speed Range

Average Write Speed
















Wondering how this compares I took another USB flash drive, a Kingston DataTraveler, and ran the 64kB write test on it. It averaged 186kB/s, over 4 times faster.

The lesson is that all USB flash drives are not created equal. Caveat emptor.


For older posts and RSS feed see the blog archives.
Chris X Edwards © 1999-2016