Skip to main content

Posts

Showing posts from 2015

Flame Graphs vs Instruments in OS X: using Intel's Performance Counters

TL; DR: as of last update for OS X 10.11 / Instruments.app 7.1, you can't really create meaningful CPI Flame Graphs on OS X because of bugs in Apple's tools, both GUI and command-line. There are some alternatives and workarounds; for an alternative to a CPI Flame Graph, Instruments.app might be good enough. I sent 6 bug reports to Apple, and 5 of them got marked as duplicates; so maybe some Instruments post-7.1 will get good enough to allow the data extraction needed for real Flame Graphs. I have been trying to generate Brendan Gregg's Cycles-Per-Instruction Flame Graphs  on OS X (10.10), mostly to check cache-related CPU stalls. However, after working on it for a good while, it's looking to me like the given method is somewhat shaky, and the same or better insights about the code can be gotten more easily; partly thanks to Instruments.app,  … a nd partly in spite of Instruments.app.

List the DTrace providers in your machine

I don't see any official way to list the DTrace providers; you can seemingly only list ALL the probes, the >300K of them (in my Mac right now), and then you have to deal with the multitude of providers instantiated multiple times for different PIDs. So here's a small AWK script to list the unique providers, how many instances of each are there, and how many providers are attached to each PID:

Best practices for a (GNU) makefile in the XXI century

This is not really a tutorial on makefiles; there are lots of those around the web. But most of those are very outdated, and/or follow dubious practices. You'll end up with a makefile which was OK for a make and a compiler from the 90's, maybe even around year 2000. Even the GNU make manual recommends unnecessarily complicated things, given the capabilities gcc has grown in the last decade . So, if you know how makefiles generally work (it's enough to know what a rule, a recipe and a variable is), and want to improve yours or know of better options, the following may help.

Fred Brooks vs Dijkstra?

In the 60's, Freed Brooks led the development of the IBM/360 system and its OS. The experience made him write the famous The Mythical Man-Month. Turns out that Dijkstra also wrote about that system in his EWD255. And everything he complained about on that system is the standard nowadays! Sounds like he considered that a lot of the complexity that should be fixed by the computer is being dumped on the programmer; that the features touted by the IBM/360’s OS are in fact partial fixes to the bad design of the computer:

"Cómo reconocer cuándo alguien es de izquierdas o derechas" - volumen II

Éste era uno de esos estúpidos chistes que van por ahí, de mail en mail o incluso de whatsapp en whatsapp. Pero me resultó suficientemente tendencioso (por supuesto hacia lo buenos que son los pobrecitos de la derecha y lo malos que son los abusones de la izquierda - por qué siempre este tipo de cosas llevan esa orientación? *) que tuve que escribir una 2a versión, aún más clara sobre lo que piensan los de derecha - o al menos lo que parece que piensan los que yo conozco ;P.

My first official Linux kernel patch

Well, that took some time. Quite an exacting process… which makes you get a new perspective of how Linux is made, and what it takes to keep loose collaboration at a high quality level. And interesting too how such a simple patch evolved. First it made me think of the bike shed …

git mental model

Finally I managed to get a mental model of git that allows me to do everything without needing to google around. And this is a quick memory dump. There are other git cheatsheets, but this is mine.

Modelo mental de git

Por fin conseguí hacerme un modelo mental de git que me permite hacer de todo sin necesidad de google ni esquemas ni Stack Overflow ;P. Y ésta es mi chuleta / "volcado de memoria". Parece que no hay muchas cosas así en español; a ver si le sirve a alguien. La idea era mantenerlo muy corto y al grano — como una chuleta, vaya. Asumo que sabes de qué va en general git y qué son cosas como un puntero y una lista simplemente enlazada. Si hay interés lo expandiré en algo más "tutorial".

6 tips to survive Codility tests

Well, it happened. When applying for a job, I got sent to a Codility test. And even though I guess I already had some good practice with them, I managed to do badly in stupid ways – ways that 2 years ago I had already thought about and even taken notes on. Just, in the heat of the moment I forgot about those rules of thumb. And in fact I think these hints should be given by Codility themselves – because if not you are practically ambushed, even more so if you didn't take the time to thoroughly explore how they work. So here are my hints-to-self. The summary is: don't think of this as a coding interview; this is rather about getting something working, ASAP.

Swapping bottom left and right panes (content and patch summary/file tree) in gitk

Gitk (as of git 2.4.2) has its bottom left and right panes the other way round to what I like: the bottom right shows the file tree or the patch summary, while the bottom left shows the contents of what is selected on the right. Isn't that kinda non-standard? There is no official way to swap those panes, so here's a little hacky patch to do it.

Towards functional

(another entry in the "let the greats make my points" series …) At some point I was getting uncomfortably close to the expressive possibilities of plain old C , and started learning C++. But C++ always had to me this air about it connecting it to UML excesses, to baroque Design Patterns for things that might have been expressed with a handful of words, to "big, spongy frameworks" (as Yegge said?)… the kind of things that made me wary of going into J2EE to begin with, some long time ago. 

Great minds think alike…

… or, "using quotes by well-known people to put forward possibly unpopular points" ;P Sometimes I have a fully formed opinion to write about; lots of times I don't, but I have an intuition of where I want to go. And those times seeing what some of the "greats" in the field think can be a bit of a beacon.

Eclipse CDT configuration for big, makefile-based projects

It's been kinda hard to get Eclipse to work well with big CDT projects (say, the Linux kernel, or even a BuildRoot project including the Linux kernel). The documentation for Eclipse is between non-existent and unhelpful, and I only could find a post that talked specifically about preparing an Eclipse project for the Linux kernel . But that post explains nothing, and does some arbitrary things. So this is the generalization of that.

Qué hacer con un colinabo - receta polaca

Unos amigos se encontraron con un colinabo recientemente y pidieron ideas sobre qué hacer con ello. Me resultó gracioso, porque la primera vez que vi un colinabo (estando ya en Polonia) me pareció también muy extraño (imagina que te encuentras en el campo algo así pero pintado con spray metálico: yo me mantendría alejado!)

Stopping OS X's from storing locally IMAP messages

TL;DR: Mail.app wants you to download your messages even if you change manually the account .plist. Forget about it. I wanted to stop Mail.app in OS X 10.10 Yosemite from caching locally my IMAP messages. Once upon a time there was right there in Mail.app an option to do just that, but for the last couple of OS versions the only option shown there is whether to download the attachments or not.

Using OS X’s syslogd to receive log messages from the network

TL;DR: avoid this buggy mess and go with macports & syslog-ng. You'll finish faster and saner. [Updated 2 times] This sounds like should be easy, but OS X is a moving target because of all the infrastructure changes they have been making for the last few OS releases. Yes, there is a syslogd, but it is some half-hollowed out thing and “others” do most of the work. Syslogd does NOT open an UDP socket, launchd does and feeds it to syslogd. Syslogd does NOT (really) receive the UDP packets, a plugin does it. Syslog does NOT parse the UDP message, ASL (Apple System Log?) does. Syslogd does NOT filter the messages and store them into “logs”, ASL does. So why there is a syslogd at all, apart from giving a slight sense of false security? (As in, “c’mon, there’s syslog, can’t be too difficult”). No idea. If I had seen how complicated this was going to get I would have bailed out and used syslog-ng from macports. Anyway. So the first step is to enable UDP reception. The manpage f