Archive for August, 2008

Homeopathic Water Reclamation

The theory of homeopathy is that the adding something to pure water gives it a pattern of some sort. That pattern remains when more water is added. Thus diluting the solution does not change its effect. This is, of course, nonsense, although homeopathic remedies are sold in every drugstore and supermarket.

If we believe the theory, though, I wonder when the pattern goes away. More and more communities are turning to reclamation of waste water to address their water needs. Waste water in this country is rich with vitamins, pharmaceuticals, and, yes, homeopathic remedies. Those are all patterning the water. Could those patterns survive the reclamation process? If not, why not? Could water reclamation be giving us huge homeopathic overdoses?

Comments (4)

GCC Inline Assembler

GCC’s inline assembler syntax is very powerful and is the best mechanism I know of to mix assembly code and optimized C/C++ code. It lets you take advantage of assembly features like add-with-carry or direct calls into the kernel without losing optimizations. I don’t know of any other approach which supports that.

That said, the inline assembler syntax is also a set of traps for the unwary. Because the compiler applies optimizations around the assembler code, the inline assembler construct must precisely describe what the inline assembler code does. This is done by using constraints and by listing registers and memory that are clobbered—changed in a way which can not be easily described. Constraints are underdocumented, machine specific, and easy to get wrong.

For a complex and underdocumented construct like inline assembler, it is naturally tempting to simply copy some existing example. Unfortunately, even minor changes to the assembler code can require changes to the constraints. Unfortunately, there is no automated way to check whether you got them right. Unfortunately, it is common for incorrect constraints to work fine in simple cases and break in complex one, or to work fine with one gcc release and break with another.

So using inline assembler really requires reading and understanding the documentation. In particular the = and & constraints must be used correctly. On non-orthogonal machines like the x86 the register class constraints must be used correctly. In many cases it will be better to simply write the assembler code in a separate file and call it.

Several years ago I sketched out a different approach that might be easier to use in some cases. However, actually implementing something along those lines requires embedded the assembler into the compiler. This is unlikely to ever actually happen. I’m certainly not working on it.

Comments (6)


These are things I wonder about Iraq these days.

  • Things are clearly improving in that fewer people are being killed.
    • How much of that is due to completion of religious cleansing of neighborhoods? How many mixed neighborhoods remain?
    • How many people are returning to Iraq from abroad? At one time millions of Iraqis had left.
  • What’s up with Moktada al-Sadr? He backed down in Sadr City. Is he ready to join the political process in the upcoming provincial elections?
  • Most of the people holding formal political power did not live in Iraq under Saddam.
    • Will those people be able to win elections if the Sunnis and the Sadrists vote whole-heartedly?
    • If the provincial elections do bring in new people, will they be less tied to Iran?
  • There is an old joke about elections when Islamists run: one man, one vote, once. Can that be avoided in Iraq?
  • A major reason for the invasion was to get a stable, friendly, oil producer. That has still not succeeded. Does it still matter?
  • The civilian economy in Iraq is still wrecked; most people making money are on a government or U.S. payroll. This is not unlike other petrocracies, but it’s not a good thing. Can we do anything to change this?
  • I continue to believe that the U.S. should get out as soon as possible. Maliki has suggested that U.S. forces should leave by 2010. Is there anything stopping us from doing just that?


The Golden Age

My father’s father bought a new car every year. He and my grandmother had two cars. Every year he traded in the older one and bought a new one. There were two car dealerships in town, and he alternated each year.

One measure of the wealth of a society is what it can afford to discard. By that measure we are not as wealthy as we used to be; very few people buy a new car every year these days. Or, perhaps, my grandfather’s society was not as wealthy as it thought it was: perhaps their trash was incurring a hidden cost, a cost which we are paying today.

Our society has a common notion of progress. We think that things are getting better. Periodically some poll comes out saying that people think their children won’t be as well off as they are, and that generally causes some handwringing and comments that that has never happened in the U.S.

In some ways, we clearly are better off today–medicine today is vastly better than it has ever been. Admittedly our unhealthy diet may be causing average lifespan to decrease, but that is a different problem. However, if you measure success by material consumption–which seems like a natural measure in a capitalist society–then I’m not sure that we are better off than we used to be. We face limits, we recycle, we conserve. These are not issues that our country faced fifty years ago. That we face them now, is that maturity? Or poverty?

Comments (3)

Multi Debugging

Many programs these days are written using multiple threads, multiple processes, and multiple languages. Our current debugging solutions don’t cope particularly well with any of those.

gdb supports multiple threads. However, the interface is hard to work with. You have to select which thread you want to look at. Threads are referred to using numbers which are relatively arbitrary; it would be helpful to be able to say things like “show me the server thread.” When a thread releases a lock, it would be helpful to be able to automatically switch to the thread which acquires the lock.

When debugging multiple processes, the most interesting case is handling remote calls between the processes. It would be desirable to be able to switch easily from the process making the call to the process executing the call. Naturally multiple processes may be running on different systems, so this requires communicating with different machines during the debugging session. Multi process core files would also be interesting.

Debugging multiple languages is a difficult case, but one applicable to many web based applications. It’s normal for code to move in and out of a scripting language, such as Python, and underlying C/C++/Java code. In the multiple process case you may also have some code running in a browser written in Javascript.

For code with strong interfaces, multi-process and multi-language debugging is less interesting. However, the reality of today’s programs is that they aren’t written with strong interfaces, and program logic moves between different components. A flexible and powerful debugger could be very useful.

There is a lot of interesting work going on with gdb these days. Making gdb more powerful is hard, but I hope that it will be possible.


« Previous Page « Previous Page Next entries »