Debounce key-presses to improve responsiveness

This idea is based on a patch from Yiding Jia, with some additional
logic added to ensure that potentially expensive matching only occurs
when really needed (ie. we don't re-match just because you hit a cursor
up or down key).

Not sure what the sweet spot for the debounce interval is, so starting
with 50ms, and making it configurable. I suspect that on really large
hierarchies you might want this to be higher (say, 100, 150 or even
200ms) in order to reduce the likelihood of unwanted match computations
kicking off just because you happened to slow a little in typing.

Note the use of augroups here to ensure that we don't keep adding more
and more autocmds to the buffer (depending on the platform, the buffer
will be cleaned up with bwipeout! or bunload!; in practice the same
buffer is usually used over and over again, so we wind up with a single
autocmd assigned to a buffer designated as `<buffer=2>` or similar).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Move FileScanner into a FileScanner::RubyFileScanner subclass

We want to add support for different scanning strategies. This commit
should be a no-behavior change, as we're just moving the Ruby-specific
logic from FileScanner down into a new FileScanner::RubyFileScanner
subclass.

The next step will be to show how another subclass can be used with
different performance characteristics.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Add `find`-based scanner

This is another enhancement based off of a patch by Yiding Jia. It
allows you to choose to use a `find`-based scanner, which may be
substantially faster than doing it all in Ruby.

I have to benchmark this; it's possible that by respecting 'wildignore'
the speed benefits of shelling out to a pure-C tool will be negated
(Yiding's original patch did no filtering). At least as a starting
point, I want this to be as close to feature-parity as possible with the
Ruby scanner, which means that it respects g:CommandTMaxDepth,
g:CommandTMaxFiles, g:CommandTScanDotDirectories, and
g:CommandTWildIgnore.

To try out the scanner, use:

  :let g:CommandTFileScanner='find'

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Silence a warning from Linux `find`

`find` on Linux (at least, on the CentOS 5.2 box I am testing on)
doesn't like the order of these arguments. Specifically, it prints the
following to stderr:

  find: warning: you have specified the -maxdepth option after a
  non-option argument -name, but options are not positional (-maxdepth
  affects tests specified before it as well as those specified after
  it).  Please specify options before other arguments.

Harmless, but an eyesore nonetheless, so let's change it.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Silence potentially noisy stderr from `find` command

`find` may spew a bunch of harmless but annoying messages to stderr --
things like permissions errors and such. On a large project, the
likelihood of running into one of these edge cases is much higher. For
the benefit of such projects, let's just swallow stderr.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Fix typo in Controller#delete method

This typo was originally introduced in commit ff72bd9bdffaf84247288a0.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Fix typo in Controller#delete method

This typo was originally introduced in commit ff72bd9bdffaf84247288a0.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Add partial work-in-progress of fswatcher process

Just some simple benchmark operations to get a sense of whether
this thing can work. More to come.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Add #bind method for use with prepared statements

Hopefully this won't be confused with Function.prototype#bind. I am not
too happy with the verbosity of this, but it is somewhat cleaner than
what was there before. I'll keep thinking on it and see if I can come up
with a better way.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Add some more DB operations to complete benchmarks

Here are the results from a sample run of an in-memory database
with 400,000 rows (ie. 400k INSERTs, 100k UPDATEs, a SELECT of 400k
rows, and 100k DELETEs).

  Timings:
    Connect 0.002 seconds
    PRAGMA 0.001 seconds
    CREATE TABLE 0.001 seconds
    CREATE INDEX 0.001 seconds
    INSERT 21.168 seconds
    UPDATE 1 hour, 46 minutes, 58 seconds
    SELECT 0.953 seconds
    DELETE 1 hour, 27 minutes, 8 seconds
  Total: 3 hours, 14 minutes, 29 seconds

It is pretty slow... I'm particularly surprised at how slow UPDATEs are
compared to INSERTs. Likewise, the DELETE performance is surprising.

This might actually be OK as large parts of the tree are unlikely to be
changing at a time.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Add args passing to fswatcher

The "-p/--port" option does nothing right now, but it will later.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Disperse row operations during benchmarking

Just spread it out a bit so we're not always working on the first 25% of
the table. Still, the workload isn't super representative of real world,
but that's probably ok.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Move DB wrapper into a separate file

Keep this somewhat extraneous detail out of the way.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Move options parsing into separate file

Another somewhat distracting detail moved out the way.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Exit on showing help

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Simplify requiring of db and argv modules

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Finally commit of fswatcher files

I've ended up tacking a different route here, but before I kill all the
files I want to leave a snapshot of how things were in the history.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Remove contrib directory

It was an experiment, and I've since found what looks to be a much
better and cheaper way.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Add "watchman" file scanner and accompanying documentation

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Merge branch 'pluggable-file-scanners' into next

* pluggable-file-scanners:
  Add "watchman" file scanner and accompanying documentation
  Remove contrib directory
  Finally commit of fswatcher files
  Simplify requiring of db and argv modules
  Exit on showing help
  Move options parsing into separate file
  Move DB wrapper into a separate file
  Disperse row operations during benchmarking
  Add args passing to fswatcher
  Add some more DB operations to complete benchmarks
  Add #bind method for use with prepared statements
  Add partial work-in-progress of fswatcher process
  Fix typo in Controller#delete method
  Silence potentially noisy stderr from `find` command
  Silence a warning from Linux `find`
  Add `find`-based scanner
  Move FileScanner into a FileScanner::RubyFileScanner subclass