Tagging speed improvements for Darktable (brought to you by DTrace)

Over the last few weeks I’ve been doing a bit of hacking on Darktable‘s tag suggestion code, because it is a significant usability pain point for me.

A few weeks back I wrote a post published on the Darktable.org blogabout how easy it is to be the maintainer of this application for Solaris. I also mentioned a DTrace one-liner I’d fired up to see what was going on with tag suggestions. From that one-liner my little bit of DTrace quickly escalated into variations of this:

#!/usr/sbin/dtrace -s
pid$target::dt_tag*:entry{
    self->traced = 1;
}

pid$target::dt_tag*:return{
    self->traced = 0;
}

pid$target:*sqlite*:sql*exec:entry/self->traced/{
    self->sqlt = vtimestamp;
    self->sql = copyinstr(arg1);
}

pid$target:*sqlite*:sql*exec:return/self->traced/{
    printf("sqlite \"%s\" took %d nsec",
        self->sql, vtimestamp - self->sqlt);
    self->sqlt = 0;
    ustack(30);
}