Brandon Low [Thu, 10 Feb 2011 21:23:36 +0000 (13:23 -0800)]
midx4: Fix the other side of my previous nasty bug
The previous one was a problem with midx4s generated from idx files,
this one is similar but when they are generated from other .midx4 files.
Many thanks to Aneurin Price for putting up with the awful behavior and
prodding at bup and whatnot while I was trying to make this one
disappear under a rug.
Once again, midx4 files generated prior to this patch will want to be
regenerated. Once again, only smart servers which have objects not on
the client's index cache will be effected, but they sure as hell well be
effected.
Brandon Low [Tue, 8 Feb 2011 18:43:22 +0000 (10:43 -0800)]
midx4: Fix name offsets when generated from idx
This was a nasty bug, glad it got found before release. Only effected
the server's ability to suggest .idxs so far, but would have effected
any attempt to have bup retrieve objects directly too.
Avery Pennarun [Tue, 8 Feb 2011 06:16:08 +0000 (22:16 -0800)]
Merge branch 'bloom'
* bloom:
bloom: avoid kernel disk flushes when we dirty a lot of pages.
midx4: Properly decide whether to do progress in C
midx4: Don't use Py_ssize_t, it's not in python2.4
cmd/bloom: map only one .idx file at a time.
bloom: Use truncate not writing zeros in create
bloom: Don't use function pointers in tight loops
Fix updating of bloom with additional files
ShaBloom.init(): initialize members before the assert().
cmd/bloom: actually, always use the same temp filename.
cmd/bloom: use mkstemp() instead of NamedTemporaryFile().
midx: Write midx4 in C rather than python
midx4: midx2 with idx backreferences
ShaBloom: Add k=4 support for large repositories
ShaBloom prefilter to detect nonexistant objects
mmap: Make closing source file optional
Avery Pennarun [Tue, 8 Feb 2011 03:09:06 +0000 (19:09 -0800)]
bloom: avoid kernel disk flushes when we dirty a lot of pages.
Based on the number of objects we'll add to the bloom, decide if we want to
mmap() the pages as shared-writable ('immediate' write) or else map them
private-writable for later manual writing back to the file ('delayed'
write).
A bloom table's write access pattern is such that we dirty almost all the
pages after adding very few entries; essentially, we can expect to dirty
about n*k/4096 pages if we add n objects to the bloom with k hashes. But the
table is so big that dirtying *all* the pages often exceeds Linux's default
/proc/sys/vm/dirty_ratio or /proc/sys/vm/dirty_background_ratio,
thus causing it to start flushing the table before we're
finished... even though there's more than enough space to
store the bloom table in RAM.
To work around that behaviour, if we calculate that we'll probably end up
touching the whole table anyway (at least one bit flipped per memory page),
let's use a "private" mmap, which defeats Linux's ability to flush it to
disk. Then we'll flush it as one big lump during close(), which doesn't
lose any time since we would have had to flush all the pages anyway.
While we're here, let's remove the readwrite=True option to
ShaBloom.create(); nobody's going to create a bloom file that isn't
writable.
Brandon Low [Tue, 8 Feb 2011 02:30:04 +0000 (18:30 -0800)]
midx4: Properly decide whether to do progress in C
Basically just gives us a _helpers.istty to go along with helpers.istty
and uses it to decide whether or not to write progress messages from
midx4 generation.
Avery Pennarun [Tue, 8 Feb 2011 01:41:00 +0000 (17:41 -0800)]
cmd/bloom: map only one .idx file at a time.
This massively decreases virtual memory allocation since we only ever need
to look at a single idx at once.
In theory, VM doesn't cost us anything, but on 32-bit systems we can
actually run out of address space if we try to map all the idx files at
once on a very large repo.
Brandon Low [Mon, 7 Feb 2011 17:08:00 +0000 (09:08 -0800)]
bloom: Use truncate not writing zeros in create
This lets us test more of bloom's code without writing gigabyte(s) of
zeros to disk. As noted in the NOTE: this works on all of the common
modern unixes that I checked, but may need special handling on other
systems.
Avery Pennarun [Mon, 7 Feb 2011 09:28:06 +0000 (01:28 -0800)]
cmd/bloom: actually, always use the same temp filename.
There's no reason to use a different temp filename every time, since we're
going to just be overwriting the same output file anyhow. And if we got
interrupted, we left the temp file lying around. Let's just always use the
same temp filename, which means if we get interrupted, we'll clean it up
next time.
Avery Pennarun [Mon, 7 Feb 2011 08:55:10 +0000 (00:55 -0800)]
cmd/bloom: use mkstemp() instead of NamedTemporaryFile().
Older versions of python (I tested python 2.5) don't support the
delete=False parameter to NamedTemporaryFile(). In any case, it's not
actually a temporary file since we're not planning to delete it.
Brandon Low [Mon, 7 Feb 2011 06:06:08 +0000 (22:06 -0800)]
midx4: midx2 with idx backreferences
Like midx3, this adds a lookup table of 4 bytes per entry to
reference an entry in the idxnames list. 2 bytes should be plenty, but
disk is cheap and the table will only be referenced when bup server gets
an object that's already in the midx.
Brandon Low [Mon, 7 Feb 2011 06:06:07 +0000 (22:06 -0800)]
ShaBloom: Add k=4 support for large repositories
Comments pretty much tell the story, as 3TiB is really not large enough
for a backup system to support, this adds k=4 support to ShaBloom which
lets it hold 100s of TiB without too many negative tradeoffs. Still
better to use k=5 for smaller repositories, so it switches when the
repository exceeds 3TiB.
Brandon Low [Mon, 7 Feb 2011 06:06:06 +0000 (22:06 -0800)]
ShaBloom prefilter to detect nonexistant objects
This inserts a bloom prefilter ahead of midx for efficient checking of
objects most of which do not exist. As long as you have enough RAM for
the bloom filter to stay in memory, this saves a lot of time compared to
midx files. Bloom filter is between 1/5th and 1/20th the size of midx
given the parameters I'm using so far.
Gabriel Filion [Sat, 5 Feb 2011 22:17:47 +0000 (17:17 -0500)]
options.py: update docstrings and detail optspec
The docstring on the Options class currently refers to a man page which
does not exist, and still talks about the now-removed 'exe' parameter.
Update this to be more accurate.
Add a docstring to OptDict.
Finally, the options.py file brings a concept of option spec string. Its
construction should be documented. Since we'd like the options.py file
to be a one-file drop-in so that it can be easily used in other
projects, let's document the option specs in the module's docstring.
Avery Pennarun [Sat, 5 Feb 2011 01:30:11 +0000 (17:30 -0800)]
cmd/memtest: don't die if /proc/self/status is the wrong format.
Apparently Solaris has /proc/self/status, but it's binary and so our
Linux-centric parser couldn't handle it. The data we're getting from it is
non-critical, so just ignore the parse error and let the high-level code in
report() deal with it.
Reported by henning mueller, diagnosed by Gabriel Filion. Thanks guys!
Avery Pennarun [Fri, 4 Feb 2011 11:01:33 +0000 (03:01 -0800)]
client.py: replace a never-used GitError with a ClientError.
Nobody ever tried calling that function, so it's really just an assertion
that never triggered. Which is good, because it was trying to throw an
exception that wasn't available in the current namespace.
Avery Pennarun [Thu, 3 Feb 2011 10:16:54 +0000 (02:16 -0800)]
client.py: avoid an exception when no new remote packs were generated.
This is probably pretty rare, but it can happen if you needed to download a
remote index, and that index had *all* your objects, so we did end up
writing some objects to the remote server, but it didn't end up generating
any packs. If that happened, we would try to return the contents of a
nonexistent variable.
Avery Pennarun [Tue, 1 Feb 2011 10:04:53 +0000 (02:04 -0800)]
runtests: Apparently $(wildcard) in make doesn't always sort its output.
This meant that on Solaris, tests would be run in a different order, so that
BUP_MAIN_EXTRA (set in tclient.py) wouldn't be set the same as on Linux.
In this case, we know the wildcard will always match something anyway, so we
might as well just let the shell expand it out rather than asking make to do
it.
Avery Pennarun [Tue, 1 Feb 2011 09:47:09 +0000 (01:47 -0800)]
cmd/help: earlier path.exedir() change made it not find manpages correctly.
...when the binary wasn't actually installed. Previously, it would use
sys.argv[0], which was the path to bup-help, but now it uses path.exedir(),
which has the path to bup, which is one directory up.
Avery Pennarun [Tue, 1 Feb 2011 08:22:07 +0000 (00:22 -0800)]
Merge branch 'mux'
* mux:
If you specified the port number on the command line, convert it to an int.
Add `bup daemon` command for simple socket server
Add DemuxConn and `bup mux` for client-server
Gabriel Filion [Fri, 28 Jan 2011 06:14:08 +0000 (01:14 -0500)]
t/test.sh: Fix a test for 'split' on solaris
When looking at output from a test run on Solaris, one test in the
'split' suite showed up as OK but was actually showing a diff
invocation error.
The -q argument (for quiet) does not exist on the version of diff that
is installed on Solaris. Since wvtest intercepts output from tested
commands, the -q argument is actually not needed. Remove the argument in
order to make the test execute correctly under all operating systems
that were tested thus far.
Brandon Low [Mon, 24 Jan 2011 03:31:51 +0000 (19:31 -0800)]
Combine and speed up idx->midx and bupindex merge
These two processes used almost identical algorithms, but were
implemented separately. The main difference was one was ascending and
the other was descending.
This patch reverses the cmp on index.Entry so that both can share an
algorithm.
It also cuts some overhead in the algorithm by using it.next() instead of
the next() wrapper, yielding a ~6% speedup on midx generation and index merging.
Avery Pennarun [Wed, 26 Jan 2011 03:32:27 +0000 (19:32 -0800)]
auto_midx(): report args when failing to call a subprocess.
The exception from subprocess.call() doesn't report the path it tried to use
when it prints the "No such file or directory" error, which isn't helpful
when trying to debug problems.
Gabriel Filion [Mon, 17 Jan 2011 01:38:56 +0000 (20:38 -0500)]
options: remove unused 'exe' parameter
The 'exe' parameter was added in the hope of using it for additional
contextual information in the help text that Options generates. It was
till then abandoned and was judged as superflous information.
Remove the 'exe' parameter from Options' constructor.
Brandon Low [Wed, 12 Jan 2011 01:15:53 +0000 (17:15 -0800)]
save: handle backup write errors properly
bup-save was catching all IOErrors and treating them as data-read
failures, but some of them could be backup-write errors. Have git.py
and client.py raise distinctive errors when pack write raises IOError.
Gabriel Filion [Mon, 17 Jan 2011 02:19:25 +0000 (21:19 -0500)]
cmd/init: don't spit out a traceback on init error
When an error occurs during repository creation, 'bup init' currently
lets GitError exceptions leak out, printing a backtrace to unsuspecting
users in the process.
Intercept GitError exceptions that come out of git.init_repo() and print
out the message that it contains in a more friendly manner.
Gabriel Filion [Mon, 17 Jan 2011 02:19:24 +0000 (21:19 -0500)]
git.py: error when repo's parent dir absent
Currently, when you try to initialize a bup repository inside an
unexistant directory (e.g. BUP_DIR=some_dir/bup_repo, and some_dir does
not exist), bup has to call "git init" to then obtain an error code
which is not very significant to users.
Add a check for the existence of the repository's parent directory and
throw an exception with a more meaningful error message when that
happens.
Gabriel Filion [Sun, 9 Jan 2011 02:19:37 +0000 (21:19 -0500)]
Add some notes on how to install bup on FreeBSD
I've given bup a go on FreeBSD 8.1 and everything seemed to be
functional.
Some package names are not really obvious, and the default 'make'
command doesn't like bup's GNU Make-ish Makefile. Add some notes in the
README so that people can have some pointers on what to do to get bup
fully functional under FreeBSD.
Gabriel Filion [Sun, 9 Jan 2011 02:59:48 +0000 (21:59 -0500)]
Update ls man page for new -a option
Commit 74d28e77366dba1eefbfa2beeda34bcaa835dc58, while modifying the
default behaviour for 'bup ls', introduced a new option to obtain the
old default behaviour.
Brandon Low [Sat, 8 Jan 2011 19:56:00 +0000 (11:56 -0800)]
client/server:Handle multiple suggestions and misc
There was a fixme in the code, I was doing cleanups and fixed it. There
are therefor some misc. cleanups in here along with the handling of
multiple suggested packs.
Avery Pennarun [Sat, 8 Jan 2011 09:59:55 +0000 (01:59 -0800)]
Merge branch 'next' into 'master'
* 'next':
Change server_mode=='dumb' to just a dumb_server_mode bool.
Teach bup about URLs and non-ssh remotes
Don't generate midx files in dumb server mode
Add optional dumb-server mode
git.CatPipe: set a buffer size on the subprocess to increase performance.
Improve test pass condition
Adds examples for strip, strip-prefix and graft to bup save's documentation
Adds --graft option to bup save.
Zoran Zaric [Fri, 7 Jan 2011 11:16:24 +0000 (12:16 +0100)]
Fix a bug in strip_path when prefix is a symlink
helpers.realpath() wasn't the right choice for path normalization.
The prefix itself can be a symlink, too. Now we use os.path.realpath(),
which also follows symlinks for the last element.
Avery Pennarun [Thu, 6 Jan 2011 23:27:04 +0000 (15:27 -0800)]
Merge branch 'bl/dumbserver' into next
* bl/dumbserver:
Change server_mode=='dumb' to just a dumb_server_mode bool.
Teach bup about URLs and non-ssh remotes
Don't generate midx files in dumb server mode
Add optional dumb-server mode
Brandon Low [Wed, 5 Jan 2011 17:28:23 +0000 (09:28 -0800)]
Add optional dumb-server mode
In dumb server mode, the server tells the client to load all .idx files
up front. Puts the burden of deciding what .idxs a client should work
from more squarely in the server side. This mode is activated by
putting a bup-dumb-server file in the bup repodir.
Carsten Bormann [Thu, 6 Jan 2011 21:38:10 +0000 (13:38 -0800)]
git.CatPipe: set a buffer size on the subprocess to increase performance.
apenwarr: I modified Carsten's patch slightly, since "line mode" is not
really appropriate. On my system, this patch (or Carsten's) can read 111
megabytes in 1.7 seconds instead of 2.1 seconds, or 65MB/sec instead of 52
MB/sec.
Avery Pennarun [Mon, 3 Jan 2011 04:58:35 +0000 (20:58 -0800)]
Merge branches 'gf/ls', 'gf/tag', 'zz/import-rsnapshot' and 'bl/selfindex'
* gf/ls:
ls-cmd: hide files with a leading dot by default
* gf/tag:
Refuse branch/tag names that start with a dot
tag-cmd: Some fixups
* zz/import-rsnapshot:
Adds a testcase for import-rsnapshot.
Makes import-rsnapshot use save's -f option.
Adds -f option to save to use a given indexfile.
Makefile: handle shell commands (cmd/*-cmd.sh)
Adds documentation for bup-import-rsnapshot
Adds import-rsnapshot command.
Adds documentation for save's strip option.
Adds testcases for --strip and --strip-path.
Adds a strip and strip-path option to bup save.
* bl/selfindex:
Rename receive-objects command to receive-objects-v2.
Write idxs directly rather than using git-index-pack.
Send SHAs from the client to reduce server load
Use chunkyreader() instead of manually reading multiple blocks.
Avery Pennarun [Mon, 3 Jan 2011 04:38:44 +0000 (20:38 -0800)]
Rename receive-objects command to receive-objects-v2.
...since it's incompatible with the old one. That will make it die more
spectacularly when talking to an old-style server, rather than failing in
more confusing ways.
Theoretically we could do fancy things like making our server support both
variants of receive-objects, but hey, bup is a pre-release, it shouldn't be
acquiring backwards compatibility cruft *already* :)
Avery Pennarun [Thu, 23 Dec 2010 02:08:58 +0000 (18:08 -0800)]
Skip over invalid .idx files if we find any.
There's no particular reason to make it fatal; just pretend they're not
there.
Zoran reported a bug where he had (it seems) some zero-length .idx files,
which is weird, but nothing worth aborting a backup over.
Also, fix _mmap_do() to be able to handle mmap'ing a zero-length file
without an error. It's a trivial and somewhat pointless operation, but it
shouldn't throw an exception.
Avery Pennarun [Wed, 22 Dec 2010 18:49:20 +0000 (10:49 -0800)]
cmd/server: find .idx filenames more efficiently when needed.
Rather than mapping *all* the .idx files into memory at once just to look up
a single object, just open/read/close them sequentially. This should
significantly increase the total repo size on a 32-bit system. (Of course,
it's still not very ideal; we really should have some kind of fallback mode
for when our total set of indexes starts getting too big.)