3 months Ago

Workfare instead of welfare

Published by marco on in Public Policy & Politics

I received the post Maine Just Changed Their Food-Stamp Policy… Every State Should Do This (Conservative Tribune) from a friend.

The friend wondered whether the following was a good idea. They thought it might be, but asked if I could confirm.

“[…] adults 18 to 50 years old with no children and who are able to work must do so or volunteer for 20 hours each week. Otherwise, their benefits will be limited to three months over a three-year period”

This is one of those superficially seductive ideas that keeps coming up. Basically, should the U.S. privatize and marketize the remaining social components of its safety net? Should it remove the last vestiges of mercy from its society?

They are not us

This idea assumes that people on welfare are lazy. That their inability to support themselves and their families and subsequent desperation is purely their own fault. That they deserve their fate.

But—and I think this is the most important part of all—if we believe that those on welfare deserve to be treated poorly, then those of us not on welfare are free to believe that we earned our much better lives.

There is no mercy in such a system, no acknowledgment that the system treats some much worse than others. That luck plays a large role in the lives of both the most disadvantaged and the most advantaged.

There are so many factors dooming people to poverty in America. Programs like this, that force their participants to dance for their supper, are a cruel joke. They make those of us who will never have to be part of one of these programs feel vindicated, but that feeling comes from a petty, stupid and cruel place.

Lazy. Stupid. Ignorant.

Given this presupposition, it of course makes sense to punish others for being poor, to extract what we can from them instead of supporting these parasites.

There are so many reasons other than laziness that people can’t get jobs:

  • There aren’t enough jobs that pay living wages
  • The jobs that are available are soul-killing or physically dangerous
  • The education system is a joke; There is no training for good jobs
  • The continuing education system is weak to nonexistent
  • Many “decent” jobs are out of reach for anyone without at least a bachelor’s degree
  • There is prejudice everywhere against the poor
    • Don’t have nice clothes? Forget office work
    • Can’t speak without an accent? Or slang? Forget office work
    • Bad teeth? Forget a whole slew of jobs
    • Not pretty? Overweight? Same thing.
    • Black? Hispanic?

Tantamount to slavery

Instead of giving the poor help to get them back on their feet, we give them what amount to jobs. I suppose this sounds good to some. There’s a lot of work to do and not enough people to do it.

If they don’t comply, they no longer get the benefit of the doubt. If they don’t comply, they get their super-generous benefits of a few hundred dollars per month for only three months and then nothing for thirty-three more months.

If you can’t find a job of your own—or are unwilling to do so—you have to do the job you’re given by the state. This is just a transformation of the unemployment program, though. Instead of making you seek out jobs in your area of expertise, these new programs just give you a job.

And what do you get paid for this job? The article says “or volunteer 20 hours each week”. If you have to do the work to get benefits, then it is, by definition, not volunteering. But what they mean by “volunteer” is that you’re doing the job for no salary, other than the benefits (which you used to get for free).

Welfare benefits are notoriously meager. Most recipients are scraping the bottom of the barrel by the third week of the month, no matter how well they stretch them. This is not a luxurious lifestyle.

So, even if you do get paid for your work, the salary is almost certainly far below minimum wage.

Life in the hands of the state

Under such a system, people will have a job of sorts, but far less chance to get control back over their lives.

If you spend 20 hours per week working at this shitty, super-low-paid job, do you have time to find a better one? No, you probably do not. Do you have time for your continuing education program? No to that too. What about your kids? Who takes care of them while you work? Hire a babysitter. It’s good for the economy.

It’s hard to imagine that society that converts its welfare program to something like this will pay a living wage. And you can forget about benefits or any thought for how a life is supposed to work under this regime. That’s not the taxpayer’s problem because they’re already being generous enough by throwing a few dollars and a job the recipient’s way.[1]

Don’t like it? Don’t take the extravagant benefits, you lazy bastard.

And stop whining about your kids.

You shouldn’t have had them if you can’t take care of them.


And your kids are future freeloaders.

Race to the bottom

These programs are not new. Back in the 90s, the “workfare” program was the brainchild of Bill Clinton (yep, the so-called progressive). Mayor Rudolph Guiliani implemented it in NYC by making welfare recipients work in the park system.

What happened? Their salaries were on the order of a dollar or two per hour and so they were much cheaper to hire than the current park staff. The current staff was let go and replaced with much–lower-paid unskilled labor. A win all around, right? The skilled and trained labor lost their good jobs.

Taxpayers win because they also don’t have to pay for benefits or pensions or anything. Awesome, right? Because nobody who mattered knew anyone with a good job in the park system, so the park workers might as well not even exist.

So what happens with all of those people who just lost their jobs? No problem. They go on welfare and can go right back to work in the park, but at 1/10 of their former salary without benefits or a pension. Sweet.

This kind of program gets rid of good jobs and makes everyone race to the bottom, working harder for less. It’s capitalism at its finest.

No more unions, no more pensions, no more benefits. Not for the poor. They don’t deserve it. If they did, wouldn’t they already have it?

Being poor is not a crime

The problem with this workfare kind of thinking is that it demonizes those out of work or down on their luck. It takes the few that are really lazy, makes anecdotes out of them to convince people that everyone is like that, and then making slaves out of them, more or less.

You can’t say, as the governor of Maine did, that you’re doing “all that you can to eliminate generational poverty and get people back to work” if you haven’t actually created real jobs and real job training. If the only jobs around are life-draining and crappy—and you have to get two of them to survive—are we surprised that people don’t want to do them?

Do some take advantage? Sure, they do. Do we doom the majority that actually need welfare programs and could benefit from them just to punish the few that ruin it for everyone? Do we have to do it? Is it that we can’t afford it? Or that we spend money on everything but the poor?

This program will drive people off of welfare—not because they don’t want to work, but because they don’t want to get trapped into the forced-work program of the state. They want dignity and control over their own lives, even though they’re poor. Can’t we afford to give them that?

There’s no money in helping people

If we need to spend billions and trillions to deploy to Iraq or to build the next generation of super-weapons or to start giant new agencies—like Homeland Security and the TSA—ostensibly to fight terrorism, no one says a thing.

Spend a few millions on the poor without them somehow paying us back and we’re up in arms.

We have no sense of proportion. We are not very nice.

Behavioral therapy

And we are cruel to those less fortunate. Because ill fortune is mostly why people are poor: they aren’t lucky enough to have been rewarded for the right behavior. Life has taught them that it’s not even worth trying anymore. They’re not necessarily inherently stupid or lazy; they have just learned the lesson that their lives taught them.

We continue to try because our experience has trained us that if we work hard, we achieve. How many years would you continue to work hard if you never achieved? If you were never rewarded, not even once? If life swatted you down? Every. Single. Time. Would you really keep getting back up?

Would you work as hard as you do if you were paid $150 a week after taxes? Would you keep looking for that job with the same energy after the first year of joblessness? At what point do you say “yes” to something criminal just to get some cash to feed yourself or your family?

And then you’re going to jail. Because you’re a criminal and deserve it. Because being poor pretty much is a crime.

Standing in judgment

We find it so easy to judge people about whom we know nothing. And it’s easy to lump all the poor together because most of us don’t know any of them or don’t have to sympathize with them. Or we hear stories about them from TV. Stories written by people who also probably don’t know any poor people. Or from cops, who have an adversarial relationship to them, granted them by the state. It goes on and on.

We don’t know them but we feel perfectly comfortable judging them. Only a society without empathy could make a so-called welfare system life this.

[1] I’d be delighted to be proved wrong, but am not expecting it.

The Obama Question

Published by marco on in Public Policy & Politics

“What do you think of Obama?[1]

He is Barack Hussein Obama,

44th—and first black—President of the United States of America.

Nobel Peace-prize winner.

So-called leader of the free world.[2]


The Drone Ranger.

Mr. Guántanamo.

Mr. extraordinary rendition.

Mr. N.S.A.

The whistle-blower hunter.[3]

Defender of the 0.1%.

The question above is posed in different ways, in different tones. It depends on the person posing it. If the person hates Obama—for any of a variety of reasons, into which I may go later, then the question is accompanied by a conspiratorial leer. The leer extends a hopeful olive branch, anticipating an enjoyable evening of exchanging highly questionable information about Obama and his purported policies.

If the person likes Obama, they usually hope that you don’t mention torture, the financial bailout, drones, Guantánamo, Israel or any of another host of issues on which Obama is decidedly not progressive. Even the ACA—called “Obamacare” by nearly everyone—which he would likely deem to be the major part of his legacy, crumples under more progressive scrutiny.

Heaven forfend you mention any of Obama’s campaign promises—from 2008 or 2012—because his failure to have accomplished any of them in the manner he’d promised is—according to these people—most definitely not his fault. It is the fault of the Republicans.

So, his detractors oppose everything he stands for and his supporters acknowledge that he sucks but it’s not his fault.

Whose fault is it then?

The short answer? The system sucks and good luck changing it.

That many high-ranking Republicans seem hell-bent on policies that benefit only themselves and their friends to the detriment of all others is abundantly clear. That this group also includes many Democrats is also clear. Just because only 93% of Democrats are assholes versus 95% of Republicans doesn’t make much difference to the casual observer.[4] The natural conclusion to which to come is that they’re all assholes and you won’t be off by much. Assuming this will equip you well for dealing with them all. At the least, not trusting any of them is a good start. But I digress.

Of course, if their policies benefit you, then you’ll think they’re a swell bunch of guys—and they are still, mostly, guys. But you’re in a small minority. The vast majority of people in the U.S. and the world have nearly nothing in common with their representatives, be they in the U.S. or Iran or Russia or China … or any of dozens of other countries that happily count themselves in the OECD. There are a few where the government seems to work for the people instead of the other way around—e.g. Switzerland and a handful of Scandinavian countries, perhaps—but not many of us are lucky enough to live there.

The U.S.. is definitely in the other category, where the people pretty much work for the government, but let’s not forget: the government, in turn, works for its own masters. But those masters are not us.[5]

Corporations are people, in the U.S. at least. Those are the real masters of the 21st century. It is they—and their ultra-exclusive owners—who wield the real power. They call themselves the masters of the universe and have yet to be proven wrong.

Obama: smart? dumb? a dupe? evil?

Which brings us back to Obama. He’s incredibly far removed from any one of us. He can very eloquently express viewpoints that sound as if they sympathize and even echo our own. But he’s lying. We’ll leave it to history to decide for sure whether he himself knows he’s lying—but I’m going to come out and write that anyone that smart is at least self-aware enough to know that what he says and what he does almost never line up.

I’m sure it’s frustrating to constantly have to say things that you don’t mean in order to get things done that you really want. Such is the life of a politician. It’s not easy convincing people to do things against their own best interests—or against basic morality. Which is why you have to lie to them so much.

Is Obama a dupe? No, I don’t think so. That’s giving him too much credit. It’s so easy to buy the story that he’s desperately trying to enact a progressive program in America while presiding over one of the greatest regressive swings in history. Do people think that he’s the Mr. Magoo of politics? That he accidentally swings the economy in the favor of the bankers and Wall Street while really, honestly and desperately trying to do the right thing for the vast majority of Americans? How bloody hopeful and simple-minded could you possibly be to believe that? Believing this fairy tale ensures only that Obama—or someone very much like him—will hoodwink you again.

It’s the system, stupid[6]

But we can substitute the name “Obama” with the name of any politician. I want to emphasize that I don’t think he’s special, or especially bad. He’s just the current president. He’s the same—more or less and for all practical purposes—as all the rest. He starts wars, he runs a drone-based, extra-judicial assassination program that is demonstrably criminal and evil, he lowers taxes, he gives gobs of money to large corporations (hello, health-insurance industry), he glorifies the military and showers it with endless cash and weapons programs, he allows torture while redefining it otherwise semantically, he embargoes and fights economic wars against helpless nations, he ignores climate change, expands fossil-fuel subsidies and he promulgates an arrogant trade program that is a finger in the eye of every nation in the world.

It goes on and on. Business as usual. What the hell is so different about this model versus the last one, objectively speaking?

Why hate Obama? Many seem to hate him because he is black. This can be the only reason because it’s literally the only thing that they objectively don’t like about him. This single reason is overwhelmingly influential in how people form an opinion of him that they ignore a veritable slew of reasons that they should like him, all political and policy-oriented in nature. Reasons that should, by all rights, be much more important to a person than his skin color, but there you have it—man is a frail creature and a fallen one.[7]

Anti-progressives should love Obama

Yes, they should! He’s done absolutely everything he could to make them love him.

Bankers like Obama; he does everything they like. Republicans hate him, but he does almost everything like a Republican. He funnels tons of cash to the richest in our land and neglects everything that would benefit the poor. During his entire administration (and part of Bush’s) all of the income increase has been captured by the top 1%. Everyone else went backward. Is this the mark of a progressive? Only in a country as broken as the U.S., perhaps.

Even the ACA is a sop to insurance companies—the far more progressive single-payer model was swept off the table by the Obama administration even before negotiations started. People don’t remember that he didn’t even fight for it; he never wanted it.

Obama has the sweetest gig in politics: everything he wants, the Republicans want the exact opposite with a religious zeal. So he can say he wants the most outlandishly progressive things and he is nearly assured that the Republicans will deliver America the exact opposite. He looks like he’s trying to save humanity, and the Republicans deliver the regressive program he actually wanted.

Support is opposition; war is peace;

His recent support of net neutrality is a good example. What are the odds that the Internet will be regulated as a utility with the Republicans in charge for the next two years? Vanishingly small. What are the odds that it will happen if Obama wants it to happen? Zero percent.

The exact same goes for the much-ballyhooed climate agreement with China. More smoke and mirrors that looks progressive, but is all about meeting voluntary targets. China will probably actually meet theirs. The U.S.? With a Republican-controlled Congress and Senate? Not a fucking chance by Peter Lee (CounterPunch). But Obama gets the progressive praise for “trying”.[8]

So why does Obama support these things now, when he was all wishy-washy about it before? Hard to say.

I would like to think that it’s because Obama has found a backbone and realized that he has nothing to lose by finally standing up for what he believes in. I’ve always said that he should have been doing exactly that, that he could at least stand for what he believes in rather than compromising all the time and getting nothing out of it.

But if you have a hint of cynicism in you, you’ll be gut-laughing at my naiveté right now. Hell, I’m laughing at me for even having written it. This is the story that Obama is selling. Do not buy it.

I think that it’s much more likely that this is yet another example of something that Obama doesn’t really believe in but that he thinks he has to say in order to seal his legacy as a progressive president—because history has little do with reality, and American history even less so.

Or maybe he really is just manipulating the Republicans into doing what they all really want: the further privatization of America and the world, the promulgation of the single-minded and simplistic breed of capitalism that we seem to be stuck with.

Is he ineffective because he’s stupid? Or too smart? Too principled? His opposition is too evil? Is he actually effective?

Who knows? Who cares?

How many more years do we have to waste thinking about this?

What matters is that he is not part of the solution for the real problems that we have. That’s all you need to know, I think.

[1] A long while back, a reader asked me if I couldn’t write an article about Obama. Over three months later and I was finally inspired to do so. Unlike the two examples I give in the article, he was actually genuinely interested to know. Apologies for the delay.
[2] I suspect strongly that he only called that—at least non-sarcastically—in the U.S.
[3] With a nod to Hans Landa’s nickname in Inglourious Basterds
[4] Totally making these numbers up—but they feel right.
[5] I’m going out on a limb and assuming that you’re not in the 1% or the 0.1% or the 0.01% and gracing my blog with your presence. And if you are and haven’t been offended away? Fantastic!
[6] To paraphrase James Carville.
[7] To paraphrase the always delightful, pure of hatred and sorely missed Alexander Cockburn.
[8] Hell, hard-core Obama supporters probably give Obama credit for landing that probe on the comet himself. Even though it’s an E.S.A. venture.

The Road to Quino 2.0: Maintaining architecture with NDepend (part I)

Published by marco on in Programming

Full disclosure

A while back—this last spring, I believe—I downloaded NDepend to analyze code dependencies. The trial license is fourteen days; needless to say, I got only one afternoon in before I was distracted by other duties. That was enough, however, to convince me that it was worth the $375 to continue to clean up Quino with NDepend.

I decided to wait until I had more time before opening my wallet. In the meantime, however, Patrick Smacchia of NDepend approached me with a free license if I would write about my experiences using NDepend on Encodo’s blog. I’m happy to write about how I used the tool and what I think it does and doesn’t do.[1]

History & Background

 Quino's first commitWe started working on Quino in the fall of 2007. As you can see from the first commit, the library was super-small and comprised a single assembly.

Fast-forward seven years and Version 1.13 of Quino has 66 projects/assemblies. That’s a lot of code and it was long past time to take a look a more structured look at how we’d managed the architecture over the years.

I’d already opened a branch in our Quino repository called feature/dependencyChanges and checked in some changes at the beginning of July. Those changes had come as a result of the first time I used NDepend to find a bunch of code that was in the wrong namespace or the wrong assembly, architecturally speaking.

Sidebar: Keeping branches mergeable

I wasn’t able to continue using this branch, though, for the following reasons.

  1. I got the hang of NDepend relatively quickly and got a bit carried away. Using ReSharper, I was able to make a lot of changes and fixes in a relatively short amount of time.
  2. I checked in all of these changes in one giant commit.
  3. I did this all five months ago.
  4. There have been hundreds of subsequent commits on the master branch, many of which also include global refactoring and cleanup.
  5. As a result of the above, merging master into feature/dependencyChanges is more trouble than it’s worth.

Release Methodology

With each Quino change and release, we try our hardest to balance backward-compatibility with maintainability and effort. If it’s easy enough to keep old functionality under an old name or interface, we do so.

We mark members and types obsolete so that users are given a warning in the compiler but can continue using the old code until they have time to upgrade. These obsolete members are removed in the next major or minor upgrade.

Developers who have not removed their references to obsolete members will at this point be greeted with compiler errors. In all cases, the user can find out from Quino’s release notes how they should fix a warning or error.

The type of high-level changes that we have planned necessitate that we make a major version-upgrade, to Quino 2.0. In this version, we have decided not to maintain backward-compatibility in the code with Obsolete attributes. However, where we do make a breaking change—either by moving code to new or different assemblies or by changing namespaces—we want to maintain a usable change-log for customers who make the upgrade. The giant commit that I’d made previously was not a good start.

Take Two

Since some of these changes will be quite drastic departures in structure, we want to come up with a plan to make merging from the master branch to the feature/dependencyChanges branch safer, quicker and all-around easier.

I want to include many of the changes I started in the feature/dependencyChanges branch, but would like to re-apply those changes in the following manner:

  • Split the giant commit into several individual commits, each of which encapsulates exactly one change; smaller commits are much easier to merge
  • Document breaking changes in the release notes for Quino 2.0
  • Blog about/document the process of using NDepend to clean up Quino[2]

So, now that I’m ready to start cleaning up Quino for version 2.0, I’ll re-apply the changes from the giant commit, but in smaller commits. At the same time, I’ll use NDepend to find the architectural breaks that caused me to make those changes in the first place and document a bit of that process.

Setting up the NDepend Project

I created an NDepend project and attached it to my solution. Version 1.13 of Quino has 66 projects/assemblies, of which I chose the following “core” assemblies to analyze.

 Initial assemblies

I can change this list at any time. There are a few ways to add assemblies. Unfortunately, the option to “Add Assemblies from VS Solution(s)” showed only 28 of the 66 projects in the Quino solution. I was unable to determine the logic that led to the other 38 projects not being shown. When I did select the projects I wanted from the list, the assemblies were loaded from unexpected directories. For example, it added a bunch of core assemblies (e.g. Encodo.Imaging) from the src/tools/Quino.CodeGenerator/bin/ folder rather than the src/libraries/Encodo.Imaging/bin folder. I ended up just taking the references I was offered by NDepend and added references to Encodo and Quino, which it had not offered to add.[3]

The NDepend Dashboard

Let’s take a look at the initial NDepend Dashboard.

 Initial NDepend Dashboard

There’s a lot of detail here. The initial impression of NDepend can be a bit overwhelming, I supposed, but you have to remember the sheer amount of interdependent data that it shows. As you can see on the dashboard, not only are there a ton of metrics, but those metrics are also tracked on a time-axis. I only have one measurement so far.

Any assemblies not included in the NDepend project are considered to be “third-party” assemblies, so you can see external dependencies differently than internal ones. There is also support for importing test-coverage data, but I haven’t tried that yet.

There are a ton of measurements in there, some of which interest me and others that don’t, or with which I disagree. For example, over 1400 warnings are in the Quino* assemblies because the base namespace—Encodo.Quino—doesn’t correspond to a file-system folder—it expects Encodo/Quino, but we use just Quino.

Another 200 warnings are to “Avoid public methods not publicly visible”, which generally means that we’ve declared public methods on internal, protected or private classes. The blog post Internal or public? by Eric Lippert (Fabulous adventures in coding) covered this adequately and came to the same conclusion that we have: you actually should make methods public if they are public within their scope.

There are some White Books about namespace and assembly dependencies that are worth reading if you’re going to get serious about dependencies. There’s a tip in there about turning off “Copy Local” on referenced assemblies to drastically increase compilation speed that we’re going to look into.

Dependencies and cycles

One of the white books explains how to use namespaces for components and how to “levelize” an architecture. This means that the dependency graph is acyclic—that there are no dependency cycles and that there are certainly no direct interdependencies. The initial graphs from the Encodo and Quino libraries show that we have our work cut out for us.

 Encodo & Quino Dependency Matrix Encodo interdependencies Quino interdependencies

The first matrix shows the high-level view of dependencies in the Encodo and Quino namespaces. Click the second and third to see some initial dependency issues within the Encodo and Quino assemblies.

That’s as far as I’ve gotten so far. Tune in next time for a look at how we managed to fix some of these dependency issues and how we use NDepend to track improvement over time.

[1] I believe that takes care of full disclosure.
[2] This is something I’d neglected to do before. Documenting this process will help me set up a development process where we use NDepend more regularly—more than every seven years—and don’t have to clean up so much code at once.
[3] After having read the recommendations in the NDepend White Book—Partitioning code base through .NET assemblies and Visual Studio projects (PDF)—it’s clear why this happens: NDepend recommends using a single /bin folder for all projects in a solution.

Optimizing compilation and execution for dynamic languages

Published by marco on in Programming

The long and very technical article Introducing the WebKit FTL JIT provides a fascinating and in-depth look at how a modern execution engine optimizes code for a highly dynamic language like JavaScript.

To make a long story short: the compiler(s) and execution engine optimize by profiling and analyzing code and lowering it to runtimes of ever decreasing abstraction to run as the least dynamic version possible.

A brief history lesson

What does it mean to “lower” code? A programming language has a given level of abstraction and expressiveness. Generally, the more expressive it is, the more abstracted it is from code that can actually be run in hardware. A compiler transforms or translates from one language to another.

When people started programming machines, they used punch cards. Punch cards did not require any compilation because the programmer was directly speaking the language that the computer understood.

The first layer of abstraction that most of us—older programmers—encountered was assembly language, or assembler. Assembly code still has a more-or-less one-to-one correspondence between instructions and machine-language codes but there is a bit of abstraction in that there are identifiers and op-codes that are more human-readable.

Procedural languages introduced more types of statements like loops and conditions. At the same time, the syntax was abstracted further from assembler and machine code to make it easier to express more complex concepts in a more understandable manner.

At this point, the assembler (which assembled instructions into machine op-codes) became a compile which “compiled” a set of instructions from the more abstract language. A compiler made decisions about how to translate these concepts, and could make optimization decisions based on registers, volatility and other settings.

In time, we’d graduated to functional, statically typed and/or object-oriented languages, with much higher levels of abstraction and much more sophisticated compilers.

Generally, a compiler still used assembly language as an intermediate format, which some may remember from their days working with C++ or Pascal compilers and debuggers. In fact, .NET languages are also compiled to IL—the “Intermediate Language”—which corresponds to the instruction set that the .NET runtime exposes. The runtime compiles IL to the underlying machine code for its processor, usually in a process called JIT—Just-In-Time compilation. That is, in .NET, you start with C#, for example, which the compiler transforms to IL, which is, in turn, transformed to assembler and then machine code by the .NET runtime.

Static vs. Dynamic compilation

A compiler and execution engine for a statically typed language can make assumptions about the types of variables. The set of possible types is known in advance and types can be checked very quickly in cases where it’s even necessary. That is, the statically typed nature of the language allows the compiler to reason about a given program without making assumptions. Certain features of a program can be proven to be true. A runtime for a statically typed language can often avoid type checks entirely. It benefits from a significant performance boost without sacrificing any runtime safety.

The main characteristic of a dynamic language like JavaScript is that variables do not have a fixed type. Generated code must be ready for any eventuality and must be capable of highly dynamic dispatch. The generated code is highly virtualized. Such a runtime will execute much more slowly than a comparable statically compiled program.

Profile-driven compilation

Enter the profile-driven compiler, introduced in WebKit. From the article,

“The only a priori assumption about web content that our engine makes is that past execution frequency of individual functions is a good predictor for those functions’ future execution frequency.”

Here a “function” corresponds to a particular overload of a set of instructions called with parameters with a specific set of types. That is, suppose a JavaScript function is declared with one parameter and is called once with a string and 100 times with an integer. WebKit considers this to be two function overloads and will (possibly) elect to optimize the second one because it is called much more frequently. The first overload will still handle all possible types, including strings. In this way, all possible code paths are still possible, but the most heavily used paths are more highly optimized.

“All of the performance is from the DFG’s type inference and LLVM’s low-level optimizing power. […]

“Profile-driven compilation implies that we might invoke an optimizing compiler while the function is running and we may want to transfer the function’s execution into optimized code in the middle of a loop; to our knowledge the FTL is the first compiler to do on-stack-replacement for hot-loop transfer into LLVM-compiled code.”

Depending on the level of optimization, the code contains the following broad sections:

  • Original: code that corresponds to instructions written by the author
  • Profiling: code to analyze which types actually appear in a given code path
  • Switching: code to determine when a function has been executed often enough to warrant further optimization
  • Bailout code to abandon an optimization level if any of the assumptions made at that level no longer apply

 FTL Pipeline

While WebKit has included some form of profile-driven compilation for quite some time, the upcoming version is the first to carry the same optimization to LLVM-generated machine code.

I recommend reading the whole article if you’re interested in more detail, such as how they avoided LLVM compiler performance issues and how they integrated this all with the garbage collector. It’s really amazing how much that we take for granted the WebKit JS runtime treats as “hot-swappable”. The article is quite well-written and includes diagrams of the process and underlying systems.

Extemporizing with Greg Proops

Published by marco on in Fun

I’ve recently started listening to the Gregg Proops podcast, called The Smartest Man in the World. He has a objectively terrible LA accent that really needs getting used to, but he’s a wonderfully extemporaneous, stream-of-consciousness, improvisational comedian whose claim to fame is “Whose Line is it Anyway?”.[1]

Let’s start off with a sample from the podcast called “Hearts”. Proops was discussing how the British newspapers were disparaging “pop royalty” Jay-Z and Beyoncé for not being appropriately somber and being too self-absorbed at the Louvre:

“How else would a rapper couple whose whole life is involved with self-aggrandizement, how else would they view the Louvre? You didn’t think they were going to stand there with a fucking sketch book, did you? Take detailed notes on the fucking “Winged Victory of Samothrace”? […]”

He went on to point out that “Beyoncé made a 5-hour documentary about herself for HBO *that had no humor in it*. […]” so how could we possibly expect her to provide us with any insight on the Louvre? She doesn’t even understand the deep irony of making a 5-hour autobiography and takes herself seriously as a living icon throughout. Having noted that, we should all do ourselves a favor and forget about her place in our society while still, perhaps, appreciating the bits of good music she manages to produce.[2]

In the episode named “Periwinkle”, he addressed a sulking heckler:

“You know…you have exactly thirty seconds to change your fucking attitude from one of dismal reprobation to one of enormous respect. That’s what’s going to happen at this fucking show. Or I’m going to play the “Immigrant Song” and dance the rest of this goddamned show. And that’s the whole show. Seriously. I don’t give a shit. I can’t be fired and I’ve already got my money.”

And this is from “Mandates”, when he, once again, plays The Immigrant Song, this time on tour in Sweden.

“You know what this song is doing? It’s begging for a village to be burned to the fucking ground. I’d take all the cattle and women. I’d take mushrooms, I’d go to the Caspian Sea, I’d trade for slaves, I’d take my boats overland to fucking Volgagrad. That’s what I’d fucking do. You should be proud that you come from the land of the ice and snow and the midnight sun, where the hot springs blow.”

And then he launched into a tirade on how the world works:

“Christian white people run the entire fucking boat. And when I say ‘Christian white people’, I mean people that are different colors too, that aren’t Christian. Well, how do you include them all in one boat? I’m talking about the men who run the world, whether they’re in India, in Indonesia or Russia or America or China….they’re all of the same stripe. We’re talking about men who perceive women as objects, who perceive the poor as a detriment to society, who perceive the war machine as the machine that they must stoke and fuel, because that’s the machine that they receive all the profits from, that they perceive civil rights and freedom of expression in the world to be the biggest threat to the world—not war, not poverty, not sickness, not mayhem, but the people who lead all the countries in Africa, every single country you can think of, what they perceive as the biggest threat to the world is the fact that we would be able to speak freely to one another, share ideas and, maybe, learn something from another culture. That’s what they’re afraid of. What they’re afraid of is that we might consider each other equals at any point—because that’s not how the fucking world works. When a giant corporation sets out to make profit and growth—and those are their only two goals—the thing they want is to set us against each other. But how do you mean giant corporations? I mean giant corporations like governments. Governments are giant corporations that [work] at the behest of other giant corporations. You are living in a Utopian ideal here [Sweden] insomuch as they take all of your fucking money for taxes—but you do get something out of it, like trains that run real fucking fast and liquor stores that close before you can get there.[3]

[1] I know that’s redundant but I don’t care.
[2] You know you’re already humming “If you like it, you shoulda put a ring on it” to yourself.
[3] With the bit at the end, he circled back around to the bitchfest with which he started the show, about how the state-sanctioned and -supported liquor stores in Sweden all close just when any normal person would be thinking of buying some booze for the evening.