Some Bits: Nelson's log

17 posts in April 2013

Building unison on homebrew/mac

I thought I’d try Unison out, it’s a directory sync system that’s a bit like rsync but specifically targeted at keeping filesystems in sync in both directions. May solve my problem trying to keep two Macs together with no reasonable Internet to just Dropbox or whatever. OTOH, Unison hasn’t had much development in years. And it’s written in OCaml, oy.

Anyway, it doesn’t build right in Homebrew. Turns out the Makefile is trying to be clever with the variable $NAME and it was picking up my shell environment variable. A simple “unset NAME” before installing seems to have fixed it. Details at https://github.com/mxcl/homebrew/issues/11862

1090MHz antenna

Finally managed to take my software radio outside and watch airplanes overhead. Lots of fun stuff there. Also I built a crappy 1090MHz dipole antenna. I have no idea what I’m doing, but it seems to work reasonably well. I wonder if I can measure how well?

Thanks to @lemonodor I learned about http://www.airframes.org/ which lets me look up those 6 digit ICAO codes. For instance ae2923 flying at 16,300 is a US Air Force registered B350 King Air. I’m wondering if it’s a chase plane for drones. COUGR11 (ae2f5f) at 14,325 and SPARTA53 (053977) at 15,300. Neither of those show up in airframes, although ae2f5f may be another King Air and 053977 is a bogus code, 1234567 in octal.

MacOS ._* garbage

MacOS has this terrible habit of littering filesystems with ._ files (for the search engines: “dot underscore files”). Apparently Apple uses these files for some sort of extended metadata, extending Apple’s track record of overcomplicating file systems that goes back to the bad old days of Resource Forks. (Remember BinHex? Good times.)

OK, to be fair, having some out of the way place to put extra data around files is sometimes useful. What I hate is the way the ._ garbage breaks other tools. My latest example is rsync --delete; it won’t delete a directory with a ._ file in it. Somehow in my trying to sync up directories between two Macs via a USB disk I’ll end up with some stray ._ files that then escalate to whole stray directories full of ._ files.

 

MacOS doesn’t support static binaries

clang -static -g -o dump1090 dump1090.o anet.o -L/tmp/rtl-sdr/build/src/ -L/usr/homebrew/Cellar/libusb/1.0.9/lib/ -lrtlsdr -lpthread -lm
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

/sadtrombone. Or what’s the emotion for “Apple’s kernel team is laughing at you”?

Apple has a reasonable explanation:

A statically linked binary assumes binary compatibility at the kernel system call interface, and we do not make any guarantees on that front. Rather, we strive to ensure binary compatibility in each dynamically linked system library and framework.

So basically they moved the guarantee of compatibility from the kernel interface down into the library interfaces. I guess that sort of makes sense, only it’s different from every other Unix ever and makes simple things hard. Too bad. I have some 10 year old Linux binaries I can still run because I thought to statically link them at the time.

Next best thing is to statically link everything but the system library.

$ otool -L dump1090
dump1090:
	/tmp/rtl-sdr/build/src/librtlsdr.0.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

OK, so librtlsdr was dynamically linked. I’m not sure how to tell clang to statically link just this library. I bashed around listing .a files on the linker command line and ended up here:

$ clang -g -o dump1090 dump1090.o anet.o /tmp/rtl-sdr/build/src/librtlsdr.a /usr/homebrew/Cellar/libusb/1.0.9/lib/libusb-1.0.a
Undefined symbols for architecture x86_64:
  "_CFDictionaryCreateMutable", referenced from:
      _usb_setup_device_iterator in libusb-1.0.a(libusb_1_0_la-darwin_usb.o)
  "_CFDictionarySetValue", referenced from:
      _usb_setup_device_iterator in libusb-1.0.a(libusb_1_0_la-darwin_usb.o)
...
  "_objc_registerThreadWithCollector", referenced from:
      _event_thread_main in libusb-1.0.a(libusb_1_0_la-darwin_usb.o)

Apparently linking by naming the .a suppresses the linker’s walking of library dependencies, so now I’m not getting some of the basic system stuff expected by libusb. I tried exploring what libraries were needed with otool -l and failed. I’m doing this wrong.

software radio playing

I bought a cheap software radio to plug into my Mac. I have no idea what I’m doing and no proper antenna, but just bashing around with gqrx I’m able to listen to FM radio and understand roughly what’s going on.

Even better, I just got dump1090 running; it’s a decoder for 1090S airplane transponder signals. Even better I happened to catch Air France 083 from San Francisco to Paris, a flight I’m happy to say I’ve been on myself a few times! I’m amazed at how fast they send data, many reports a second.

Getting the software working on my Mac wasn’t too hard. I installed libusb via Homebrew, then compiled librtlsdr from sources. Didn’t install that, just hacked the dump1090 Makefile to find stuff in /tmp or wherever it happened to be. My modified Makefile plus some sample output below.

Update libusbx may be a better choice than libusb. And rtlsdr is packaged in a HomeBrew fork you can tap for GNU Radio.

CFLAGS=-O2 -g -I/tmp/rtl-sdr/include/ -Wall -W `pkg-config --cflags librtlsdr`
LIBS=-L/tmp/rtl-sdr/build/src/ -L/usr/homebrew/Cellar/libusb/1.0.9/lib/ -lrtlsdr -lpthread -lm

$ ./dump1090 --interactive
Hex    Flight   Altitude  Speed   Lat       Lon       Track  Messages Seen .
--------------------------------------------------------------------------------
ac4d44          0         0       0.000     0.000     0     5         48 sec
a78dd7          0         0       0.000     0.000     0     28        17 sec
a8b805          10950     0       0.000     0.000     0     146       3 sec
3965a9 AFR083   11875     346     37.890    -122.348   48    608       23 sec

$ ./dump1090
CRC: c3e472 (ok)
DF 0: Short Air-Air Surveillance.
  Altitude       : 11300 feet
  ICAO Address   : a26fc9

*00c1879c1bd991;
CRC: 1bd991 (ok)
DF 0: Short Air-Air Surveillance.
  Altitude       : 11300 feet
  ICAO Address   : a26fc9

*00c6079cc3e472;
CRC: c3e472 (ok)
DF 0: Short Air-Air Surveillance.
  Altitude       : 11300 feet
  ICAO Address   : a26fc9

*59a26fc99c4306;
CRC: 9c4306 (ok)
DF 11: All Call Reply.
  Capability  : Level 2 (DF0,4,5,11)
  ICAO Address: a26fc9

$ ./dump1090 --raw
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001 (currently selected)
Found Rafael Micro R820T tuner
Max available gain is: 49.60
Setting gain to: 49.60
Exact sample rate is: 2000000.052982 Hz
Gain reported by device: 49.60
*8d4005e2583d0135f7fdf5514966;
*02c18790ae0146;
*8d4005e2200815f2e37820027da5;
*02c18790ae0146;
*8d4005e2583d04ca30ac60c73091;
*02c18790ae0146;
*20000790eda525;
*02c60790763ca5;
*5d4005e2dd7ccb;
*02c18790ae0146;
*02c18790ae0146;
*8d4005e29900c99d28060e63ed38;

Here’s a screenshot of GQRX while tuned to 1090MHz. I think there’s at least one airplane transmitting when I took this; hard to be sure. There’s some horizontal lines that I’m guessing are the signal. It’s so faint above the noise floor, I’m sort of amazed it works.

Screen Shot 2013-04-24 at 8.48.13 AM

case insensitive filenames on Macs

What clown decided to make a Unix with case insensitive filenames? Oh, Apple, that’s who. I mean seriously? It’s tripped me up twice in the last day. To be fair there is an option to make a case-sensitive filesystem on Macs, but so much application software breaks if you do that it’s not a viable option.

I happen to think case-insensitive systems are generally better for humans to use than case sensitive. But Unix file systems have been case sensitive for over 40 years. Grawr.

TileStache: crappy CGI timings

I made the mistake of doing a bunch of testing of TileStache with the simple Python CGIHTTPServer. It’s a great little test apparatus, but it’s single threaded. Also it’s slow by itself.

  • CGIHTTPServer: 750ms to load a single tile, 10,000ms to load a whole map with 24 or so tiles
  • Gunicorn with 4 workers (sync): 650ms to load a single file, 2154ms to load a whole map.

Some comparisons on Gunicorn settings to load a map with 24 tiles.

  • 1 worker, default sync worker: 4800ms
  • 2 workers, default sync worker: 2500ms
  • 4 workers, default sync worker: 2300ms
  • 24 workers, default sync worker: 1700ms

Interestingly the gevent worker seems slower, also more variable. OTOH it’s necessary if you’re serving GUnicorn direct to the web, without a proxy in front.

The backend server is mostly waiting on IO to Postgres, it’s no surprise doing that in parallel will be better. All on a single 4 core 2012 iMac with some SSD-backed storage. I should add I’m doing this all without benefit of any caching, so it’s all kind of fake.

 

faking out remote syslog via netcat

Here’s how to create UDP syslog messages via nc, netcat:

echo ‘<14>sourcehost message text’ | nc -v -u -w 0 localhost 514

Replace localhost with the syslog server, of course. “sourcehost” is a string identifying the source; can be anything. The 14 is a combination of the severity (low 3 bits) and the service (high N bits). 14 = 8 + 6 which means “user message, informational”. RFC 3164 has the relevant detail. The syslog protocol is remarkably ad hoc; you can leave out the priority and it should still work. And there’s a provision for adding timestamps to the source message too. Note that syslog may suppress duplicate messages, so that may be why subsequent tests don’t show up. Unfortunately the BusyBox version of nc bundled in to Tomato doesn’t have the -u flag.

I’m doing all this to try to debug Apple’s disastrous syslog server. It has some insane binary config file to enable remote logging, and then they couldn’t leave well enough alone with syslog so they had to rewrite the whole thing with aslmanager, a daemon so awesome that most of the Google search results for it are “why is this process taking 99% of my CPU?”. It is open source at least. Anyway, asl.conf has its own different format. And then it doesn’t fix the #1 problem with syslog, which is there’s no way to log the IP address of the originator of the message. Argh!

This annoyance may be the last straw for me trying to use MacOS as a Unix server. There’s just no good reason to leave the warm embrace of Linux / Ubuntu. A quick look suggests Ubuntu 12.04 will work fine on a late 2012 Mac Mini, albeit with some required hackery for the ethernet driver.

PostGIS upgrades in Debian / Ubuntu

Repeat after me: I will dump my databases before upgrading PostgreSQL or PostGIS. I will dump my databases before upgrading PostgreSQL or PostGIS. I will dump my databases before upgrading PostgreSQL or PostGIS.

I got fed up with the 2 year old versions of GIS software in Ubuntu 12.04 so I upgraded to versions from the awesome Ubuntu GIS PPAs. However after upgrading PostGIS any spatial query gave me the error

ERROR:  could not access file “$libdir/postgis-2.1”: No such file or directory

No idea why that says “2.1” when I installed PostGIS 2.0.1 (2.0.1-2~precise3), but there it is. Googling around I realized this is a symptom of not reinstalling the PostGIS functions in the database. There’s a variety of confusing database upgrade options, and the Debian packages are very clear about not injecting any SQL for you “for safety”.

However, there is a better way! Starting with Postgres 9.1 and PostGIS 2.0, PostGIS can be installed as a simple database extension. No more futzing with template databases on creation or importing lots of .sql files in a new database. All you need to do to spatialize a new database is

create extension postgis
create extension postgis_topology

I’m not sure you can use these commands to rescue an old database that didn’t survive an upgrade, but it works great with new databases. IIRC there’s even an upgrade path for extensions. I dropped my old template_postgis2 just so I never get confused again.

Vector tile river maps

Some notes for a quick project I did with Mike Migurski’s help, making a map of California rivers using vector tiles. The river data is from NHDPlus, about 180 megs of shapefile, imported into PostGIS. It’s served as manageably small GeoJSON tiles via a TileStache VecTiles provider which slices up the data like raster map tiles. Rendered for now in Polymaps. Works well!

TileStache is already smart about simplifying the geometries it returns to roughly pixel precision, depending on tile zoom level. It’s really pretty great. But I also want to serve fewer rivers at larger scales, only show the important rivers. Need a classifier. I don’t think the propery I need is in NHDFlowlines but may be in NHDPlusAttributes, more thoughts in this GIS tutorial. Seth F advises “PlusFlowlineVAA has value-added attributes that can be joined on ComId. streamorder is the column you’re looking for. It’s the Strahler number (http://en.wikipedia.org/wiki/Strahler_number) for a given section of river.”

I ran into some problems with queries from GDAL not working with PostGIS 2.0. Used to be you could just call functions like GetSRID() etc, now you have to do ST_GetSRID(). The old GDAL 1.7 on my Debian box doesn’t know that yet and the Vector provider in TileStache relies on it, so it doesn’t work. VecTiles generates its own queries and Mike was kind enough to patch his code to use the ST_ names.

The TileStache VecTiles code only works with a spherical mercator projection, so I had to do this in PostGIS to add a reprojected column:

select AddGeometryColumn('nhdflowline', 
  'sphgeometry', 900913, 'MULTILINESTRING', 2)

update nhdflowline
set sphgeometry = 
  ST_Transform(ST_Force_2D(geom), 900913);

Here’s the TileStache config for serving vector tiles from PostGIS:

    &quot;riverst&quot;: {
      &quot;provider&quot;: {
      &quot;class&quot;: &quot;TileStache.Goodies.VecTiles:Provider&quot;,
        &quot;kwargs&quot;: {
              &quot;dbinfo&quot;: {
                &quot;host&quot;: &quot;localhost&quot;,
                &quot;user&quot;: &quot;nelson&quot;,
                &quot;password&quot;: &quot;OMGSECRET&quot;,
                &quot;database&quot;: &quot;nhd&quot;
              },
              &quot;queries&quot;: [
                &quot;select sphgeometry as geometry from nhdflowline&quot;
              ],
              &quot;clip&quot;: true
        }}}}

Some screenshots; rivers on top of the ESRI relief layer, also the “first light” with a hysterical bug where the river paths are filled, not stroked.

Screen Shot 2013-04-12 at 2.06.57 PM

Screen Shot 2013-04-12 at 2.11.40 PM

importing an ESRI shapefile to PostGIS

I don’t work with shapefiles and PostGIS enough to remember how to import a shapefile into a table. I want to import the NHDPlus dataset for rivers. There’s lots of ways to do this, here’s what’s working now in a plodding, step by step way.

  1. createdb -T template_postgis2 nhd
  2. shp2pgsql -W LATIN1 NHDFlowline.shp >| /tmp/o
  3. psql nhd < /tmp/o
  4. echo ‘CREATE INDEX “nhdflowline_geom_gist” ON “nhdflowline” USING GIST (“geom”);’ | psql nhd

This can probably be done on one line with shp2pgsql -I foo.shp | psql nhd

Getting fancier on the import (and setting the SRID to 4269):

  1. shp2pgsql -s 4269 -I -D -W LATIN1 NHDFlowline.shp | psql nhd

Related: shp2pgsql won’t look at the .prj file to figure out the projection. Figuring out a projection is still way too hard and Prj2EPSG.org failed me. This StackOverflow question and this one have a neat trick; use osgeo.osr.SpatialReference().AutoIdentifyEPSG() to guess the projection.

Update: Seth F has a nice shell script for importing a lot of useful NHD data and creating important indices.

Copying a giant file with resume on error

General rule: any computer task that takes more than an hour must be done in a way that allows resuming if aborted. So, how to copy a giant file?

rsync --partial --append --progress --bwlimit=300\
nelson@wi:~/nobackup/geodata/planet-130327.osm.pbf .

Both the --partial and --append are necessary; the --partial tells rsync not to delete when aborted, and --append tells it to pick up where it left off the next time. There’s more subtle options available too.

Python startup time

Wow, Python startup time is worse than I thought. Here’s some data from a fast Ubuntu box. I ran all commands a bunch of times to warm caches.

$ time python2.7 -c 1

real    0m0.015s
user    0m0.012s
sys     0m0.000s

$ time python3.2 -c 1

real    0m0.026s
user    0m0.024s
sys     0m0.000s

$ strace python2.7 -c 1 2>&1 | wc -l
856

$ strace python3.2 -c 1 2>&1 | wc -l
1429

$ echo >| /tmp/empty.py
$ time python2.7 -O /tmp/empty.py

real    0m0.042s
user    0m0.032s
sys     0m0.008s
$ time python2.7 -O /tmp/empty.py

real    0m0.044s
user    0m0.032s
sys     0m0.008s

$ time python2.7 -S empty.py

real    0m0.004s
user    0m0.004s
sys     0m0.000s

$ strace python2.7 -S -c 1 2>&1 | wc -l
301

That last one’s a bit of a winner; -S means “don’t load site modules” and comes from this ExpertsExchange discussion. I lose /usr/local/lib; if I manually add that in my script I get my  minimal libgit2 program down to 6ms.

scripting language timings for libgit2

Was curious if I really need to use C to write this fast git prompt thing. libgit2 has bindings for many languages, but scripting startup time can really suck. Here’s a quick test of how fast a program can be that does nothing but open the repo (on Linux, local disk).

  • C: 1ms
  • Python 2.7: 17ms
  • Python 2.7 with -S flag: 4ms
  • Lua 5.1: 2ms

No surprise Python is so slow; even the null program is 14ms or so, a weakness of stock Python. Surprisingly there is no Perl binding listed; that’d be another option for fast startup. There is one for Parrot. Also Go, which could be a suitable modern upgrade for C.

Lua’s a fun little language, I should switch my development efforts there just so I have humane strings. Can always port back to C later.

All this testing is a huge PITA because the last stable release of libgit2 is 11 months old (0.17.0) and since then they’ve changed the API in all sorts of places. My C and Python tests area against the HEAD of the github repo. Lua is against 0.17.0. This lack of stability makes me question whether libgit2 is really the right choice for something as ubiquitous and lowlevel as a shell prompt. They aren’t kidding when they say it’s alpha software, I guess.

Doesn’t help that I was in dynamic linker hell, btw. On Linux it seems to cache things pretty aggressively; I had to manually run “ldconfig” as root to get it to switch from one version of libgit to another. I used to be good at this sort of nonsense but it’s been years since I’ve worked in such primitive environments.

So, quick conclusion: Lua would work for development.

playing with libgit2

Following on my dorking around with bash prompts yesterday, I was wondering how fast one could write a program to query state from git for the command prompt. The minimal __git_ps1 function I set up there takes about 75ms to run; takes longer if I add more to my prompt. That function works by invoking git a bunch of times, maybe a custom C binary could do better?

I took a quick crack at it using libgit2. It’s been years since I wrote any C code and it was rough going. No exceptions, no useful string type, manually allocated and typed memory, ugh. Maybe I should break down and do C++. Anyway, I managed to scratch together something that prints out the branch name and hash for the current commit. With caches warm my program takes just about 30ms to run; compare 23ms for __git_ps1 if it’s only printing branch name, nothing else. Ouch, I’m slower!

Using set -x I can see what __git_ps1 is doing. The main command its forking is git symbolic-ref HEAD, which takes 10ms if I run it by itself. I wonder why my libgit2 based code is so much slower?

I still feel a custom C binary should be faster, particularly to support fancier output info. But it’s an awful lot of pain writing libgit2 code in C, I may not have the patience to press on.

Update: derp, my program isn’t slow because it’s slow. It’s slow because I was running it on my Mac off of an SMB mounted volume. If I copy my binary to local disk it’s faster than stock git as expected: 6ms vs. 10ms for git symbolic-ref HEAD. Duh.

One other note; I started playing with dtruss/dtrace to figure out what system calls the two programs were running. My code makes 135 system calls, stock git makes 178. My code opens 8 files, 3 of them from the repo (which is still SMB and therefore slow). git opens 14 files, 6 from the repo. It seems to be doing all the work on the repo files twice, not sure why. Anyway now I’m reassured my libgit2 approach could be more efficient.

#include <stdio.h>
#include <stdlib.h>
#include <git2.h>

void check_return(int rc, char * msg) {
    if (rc != 0) {
        fprintf(stderr, "%s. Code: %d\n", msg, rc);
        exit(1);
    }
}

int main(int argc, char ** args) {
    int rc;
    git_repository *repo;
    git_reference *head;

    // open the repository
    rc = git_repository_open_ext(&repo, ".", 0, NULL);
    if (rc == GIT_ENOTFOUND) {
        // No git repo; that's OK.
        exit(0);
    }
    check_return(rc, "opening repository");

    // find HEAD
    rc = git_repository_head(&head, repo);
    check_return(rc, "finding HEAD");

    int ref_type = git_reference_type(head);
    if (ref_type == GIT_REF_SYMBOLIC) {
        check_return(-999, "Cant handle symbolic targets");
        // git_reference_symbolic_target() or git_reference_resolve()??
    } else if (ref_type == GIT_REF_OID) {
        // Get the name
        const char * name = git_reference_name(head);

        // Get the hash
        const git_oid * oid = git_reference_target(head);
        char hash[7];
        git_oid_tostr(hash, 7, oid);

        // Print out what we've learned
        printf("%s %s", name, hash);
    }

    return 0;
}

git prompts for bash

I’m trying to learn more about git. I thought it’d help me to modify my bash prompt to include git status. Turns out theres lots of ways to do that. I want something simple and minimal, but maybe using color. For years my prompt has been a simple “(hostname) = “; don’t want to go crazy. (Why =? Because it doesn’t look like $ or # or %, the standard characters. I know it’s mine.) Here’s some options.

  1. Here’s a blog post with some minimal git additions to the prompt. It just invokes git symbolic-ref to figure out the branch name. Simple, easy to understand, there’s a zillion hacks like this. Here’s another.
  2. git-prompt.sh is a bash addon distributed with git that adds a shell function __git_ps1 that can be invoked from inside the shell to print state. This is as close as it gets to a “standard”. This blog post does a good job explaining it. The configuration is a mess. The code is quite complex and handles a lot of strange git situations I wouldn’t have realized were important.
  3. bash-git-prompt is a different approach that has a bit more info on the state of the repo. As nice as it looks, I’m not going to use something that invokes a Python script every time bash needs to print a prompt.
  4. GIT Prompt uses colors to convey repo state, sets the terminal title, etc. It’s a very fancy prompt, but it’s overkill for my purposes. I do like how it displays non-zero exit codes though, and it’s got a nice configuration mode.

Screen Shot 2013-04-06 at 4.34.05 PM

I settled on option #2, the “stock” git-prompt.sh. It seems to work pretty well. The biggest problem is that Ubuntu 12.04 has an old version that doesn’t support working via PROMPT_COMMAND, so there’s an ugly workaround. Also gotta love the quoting. Anyway, screenshot and configuration.

GIT_PROMPT_VERSION=`sha1sum /etc/bash_completion.d/git`
if [ "$GIT_PROMPT_VERSION" = 'c52dd44066a21660c8830f8e6bd700893e2f7569  /etc/bash_completion.d/git' ]; then
    BAD_GIT_PROMPT=1
fi

if [ -n "$PS1" ]; then
  # Figure out what prompt character to use
  P='='
  if [ $UID == 0 ]; then
    P='#'
  fi

  # Set traditional prompt
  PS1="(\h) $P ";
  PS2="> "

  # Set up git prompting if available
  declare -f -F __git_ps1 > /dev/null
  if [ $? -a \! $BAD_GIT_PROMPT ]; then
    PROMPT_COMMAND='__git_ps1 "(\h" \)\ '$P'\  " %s"'
    GIT_PS1_SHOWCOLORHINTS=1
    GIT_PS1_SHOWDIRTYSTATE=1
    GIT_PS1_SHOWUNTRACKEDFILES=1
  fi
fi

I have some concerns about running any commands at all from inside a bash prompt. First it’s notably slow, particularly on a cold cache. Even warm it’s a few hundred milliseconds, and every extra GIT_ status thing I enable makes it slower. Worse, prompt commands do bad things if the command fails. Particularly a problem if you’re inside a remotely mounted filesystem that’s hung. I don’t know if bash is smart enough to timeout commands called when printing the prompt.

Update: this prompt setup is intolerably slow for big repos like libgit2 on a network filesystem mounted via SMB from a Linux server to a mac client. I’m talking 1000-1300ms per prompt, a noticeable pause. With no GIT_PS1 environment variables (just showing branch), the git prompt takes 25ms. Adding GIT_PS1_SHOWDIRTYSTATE adds an extra 100ms. GIT_PS1_SHOWUNTRACKEDFILES is the big culprit, adding an extra 1200ms or so. No surprise, the underlying command git ls-files --others --exclude-standard is making calls to getdirentries64() for every directory, also processing .gitignore files all up and down the tree. Not sure there’s any way to make that fast on a network file system. Maybe that’s why they went through the trouble to let you override the environment variable in the local git config.

Unrelated, but also useful; git-completion.bash which adds smart completion support for the git command. Seems to rely on the bash-completion addon to bash, although the script itself is distributed with git. In Mac Homebrew it’s a separate file; on Ubuntu it’s rolled together with git-prompt.sh. Apparently that’s an upstream change from a year ago.