Mercurial > hg
view tests/test-obsolete-changeset-exchange.t @ 40326:fed697fa1734
sqlitestore: file storage backend using SQLite
This commit provides an extension which uses SQLite to store file
data (as opposed to revlogs).
As the inline documentation describes, there are still several
aspects to the extension that are incomplete. But it's a start.
The extension does support basic clone, checkout, and commit
workflows, which makes it suitable for simple use cases.
One notable missing feature is support for "bundlerepos." This is
probably responsible for the most test failures when the extension
is activated as part of the test suite.
All revision data is stored in SQLite. Data is stored as zstd
compressed chunks (default if zstd is available), zlib compressed
chunks (default if zstd is not available), or raw chunks (if
configured or if a compressed delta is not smaller than the raw
delta). This makes things very similar to revlogs.
Unlike revlogs, the extension doesn't yet enforce a limit on delta
chain length. This is an obvious limitation and should be addressed.
This is somewhat mitigated by the use of zstd, which is much faster
than zlib to decompress.
There is a dedicated table for storing deltas. Deltas are stored
by the SHA-1 hash of their uncompressed content. The "fileindex" table
has columns that reference the delta for each revision and the base
delta that delta should be applied against. A recursive SQL query
is used to resolve the delta chain along with the delta data.
By storing deltas by hash, we are able to de-duplicate delta storage!
With revlogs, the same deltas in different revlogs would result in
duplicate storage of that delta. In this scheme, inserting the
duplicate delta is a no-op and delta chains simply reference the
existing delta.
When initially implementing this extension, I did not have
content-indexed deltas and deltas could be duplicated across files
(just like revlogs). When I implemented content-indexed deltas, the
size of the SQLite database for a full clone of mozilla-unified
dropped:
before: 2,554,261,504 bytes
after: 2,488,754,176 bytes
Surprisingly, this is still larger than the bytes size of revlog
files:
revlog files: 2,104,861,230 bytes
du -b: 2,254,381,614
I would have expected storage to be smaller since we're not limiting
delta chain length and since we're using zstd instead of zlib. I
suspect the SQLite indexes and per-column overhead account for the
bulk of the differences. (Keep in mind that revlog uses a 64-byte
packed struct for revision index data and deltas are stored without
padding. Aside from the 12 unused bytes in the 32 byte node field,
revlogs are pretty efficient.) Another source of overhead is file
name storage. With revlogs, file names are stored in the filesystem.
But with SQLite, we need to store file names in the database. This is
roughly equivalent to the size of the fncache file, which for the
mozilla-unified repository is ~34MB.
Since the SQLite database isn't append-only and since delta chains
can reference any delta, this opens some interesting possibilities.
For example, we could store deltas in reverse, such that fulltexts
are stored for newer revisions and deltas are applied to reconstruct
older revisions. This is likely a more optimal storage strategy for
version control, as new data tends to be more frequently accessed
than old data. We would obviously need wire protocol support for
transferring revision data from newest to oldest. And we would
probably need some kind of mechanism for "re-encoding" stores. But
it should be doable.
This extension is very much experimental quality. There are a handful
of features that don't work. It probably isn't suitable for day-to-day
use. But it could be used in limited cases (e.g. read-only checkouts
like in CI). And it is also a good proving ground for alternate
storage backends. As we continue to define interfaces for all things
storage, it will be useful to have a viable alternate storage backend
to see how things shake out in practice.
test-storage.py passes on Python 2 and introduces no new test failures on
Python 3. Having the storage-level unit tests has proved to be insanely
useful when developing this extension. Those tests caught numerous bugs
during development and I'm convinced this style of testing is the way
forward for ensuring alternate storage backends work as intended. Of
course, test coverage isn't close to what it needs to be. But it is
a start. And what coverage we have gives me confidence that basic store
functionality is implemented properly.
Differential Revision: https://phab.mercurial-scm.org/D4928
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 09 Oct 2018 08:50:13 -0700 |
parents | f9232b0310ef |
children | 34a46d48d24e |
line wrap: on
line source
Test changesets filtering during exchanges (some tests are still in test-obsolete.t) $ cat >> $HGRCPATH << EOF > [experimental] > evolution.createmarkers=True > EOF Push does not corrupt remote ---------------------------- Create a DAG where a changeset reuses a revision from a file first used in an extinct changeset. $ hg init local $ cd local $ echo 'base' > base $ hg commit -Am base adding base $ echo 'A' > A $ hg commit -Am A adding A $ hg up 0 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg revert -ar 1 adding A $ hg commit -Am "A'" created new head $ hg log -G --template='{desc} {node}' @ A' f89bcc95eba5174b1ccc3e33a82e84c96e8338ee | | o A 9d73aac1b2ed7d53835eaeec212ed41ea47da53a |/ o base d20a80d4def38df63a4b330b7fb688f3d4cae1e3 $ hg debugobsolete 9d73aac1b2ed7d53835eaeec212ed41ea47da53a f89bcc95eba5174b1ccc3e33a82e84c96e8338ee obsoleted 1 changesets Push it. The bundle should not refer to the extinct changeset. $ hg init ../other $ hg push ../other pushing to ../other searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 2 files $ hg -R ../other verify checking changesets checking manifests crosschecking files in changesets and manifests checking files checked 2 changesets with 2 changes to 2 files Adding a changeset going extinct locally ------------------------------------------ Pull a changeset that will immediatly goes extinct (because you already have a marker to obsolete him) (test resolution of issue3788) $ hg phase --draft --force f89bcc95eba5 $ hg phase -R ../other --draft --force f89bcc95eba5 $ hg commit --amend -m "A''" $ hg --hidden --config extensions.mq= strip --no-backup f89bcc95eba5 $ hg pull ../other pulling from ../other searching for changes adding changesets adding manifests adding file changes added 1 changesets with 0 changes to 1 files (+1 heads) 1 new phase-divergent changesets new changesets f89bcc95eba5 (run 'hg heads' to see heads, 'hg merge' to merge) check that bundle is not affected $ hg bundle --hidden --rev f89bcc95eba5 --base "f89bcc95eba5^" ../f89bcc95eba5.hg 1 changesets found $ hg --hidden --config extensions.mq= strip --no-backup f89bcc95eba5 $ hg unbundle ../f89bcc95eba5.hg adding changesets adding manifests adding file changes added 1 changesets with 0 changes to 1 files (+1 heads) (1 other changesets obsolete on arrival) (run 'hg heads' to see heads) check-that bundle can contain markers: $ hg bundle --hidden --rev f89bcc95eba5 --base "f89bcc95eba5^" ../f89bcc95eba5-obs.hg --config experimental.evolution.bundle-obsmarker=1 1 changesets found $ hg debugbundle ../f89bcc95eba5.hg Stream params: {Compression: BZ} changegroup -- {nbchanges: 1, version: 02} (mandatory: True) f89bcc95eba5174b1ccc3e33a82e84c96e8338ee cache:rev-branch-cache -- {} (mandatory: False) $ hg debugbundle ../f89bcc95eba5-obs.hg Stream params: {Compression: BZ} changegroup -- {nbchanges: 1, version: 02} (mandatory: True) f89bcc95eba5174b1ccc3e33a82e84c96e8338ee cache:rev-branch-cache -- {} (mandatory: False) obsmarkers -- {} (mandatory: True) version: 1 (70 bytes) 9d73aac1b2ed7d53835eaeec212ed41ea47da53a f89bcc95eba5174b1ccc3e33a82e84c96e8338ee 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} $ cd .. pull does not fetch excessive changesets when common node is hidden (issue4982) ------------------------------------------------------------------------------- initial repo with server and client matching $ hg init pull-hidden-common $ cd pull-hidden-common $ touch foo $ hg -q commit -A -m initial $ echo 1 > foo $ hg commit -m 1 $ echo 2a > foo $ hg commit -m 2a $ cd .. $ hg clone --pull pull-hidden-common pull-hidden-common-client requesting all changes adding changesets adding manifests adding file changes added 3 changesets with 3 changes to 1 files new changesets 96ee1d7354c4:6a29ed9c68de updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved server obsoletes the old head $ cd pull-hidden-common $ hg -q up -r 1 $ echo 2b > foo $ hg -q commit -m 2b $ hg debugobsolete 6a29ed9c68defff1a139e5c6fa9696fb1a75783d bec0734cd68e84477ba7fc1d13e6cff53ab70129 obsoleted 1 changesets $ cd .. client only pulls down 1 changeset $ cd pull-hidden-common-client $ hg pull --debug pulling from $TESTTMP/pull-hidden-common query 1; heads searching for changes taking quick initial sample query 2; still undecided: 2, sample size is: 2 2 total queries in *.????s (glob) 1 changesets found list of changesets: bec0734cd68e84477ba7fc1d13e6cff53ab70129 listing keys for "bookmarks" bundle2-output-bundle: "HG20", 4 parts total bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload bundle2-output-part: "listkeys" (params: 1 mandatory) empty payload bundle2-output-part: "phase-heads" 24 bytes payload bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload bundle2-input-bundle: with-transaction bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported adding changesets add changeset bec0734cd68e adding manifests adding file changes adding foo revisions added 1 changesets with 1 changes to 1 files (+1 heads) bundle2-input-part: total payload size 476 bundle2-input-part: "listkeys" (params: 1 mandatory) supported bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-part: "cache:rev-branch-cache" (advisory) supported bundle2-input-part: total payload size 39 bundle2-input-bundle: 3 parts total checking for updated bookmarks updating the branch cache new changesets bec0734cd68e (run 'hg heads' to see heads, 'hg merge' to merge)