Commit Graph

736 Commits

Author SHA1 Message Date
Ryan Gonzalez
19a705f80d Split reflists to share their contents across snapshots
In current aptly, each repository and snapshot has its own reflist in
the database. This brings a few problems with it:

- Given a sufficiently large repositories and snapshots, these lists can
  get enormous, reaching >1MB. This is a problem for LevelDB's overall
  performance, as it tends to prefer values around the confiruged block
  size (defaults to just 4KiB).
- When you take these large repositories and snapshot them, you have a
  full, new copy of the reflist, even if only a few packages changed.
  This means that having a lot of snapshots with a few changes causes
  the database to basically be full of largely duplicate reflists.
- All the duplication also means that many of the same refs are being
  loaded repeatedly, which can cause some slowdown but, more notably,
  eats up huge amounts of memory.
- Adding on more and more new repositories and snapshots will cause the
  time and memory spent on things like cleanup and publishing to grow
  roughly linearly.

At the core, there are two problems here:

- Reflists get very big because there are just a lot of packages.
- Different reflists can tend to duplicate much of the same contents.

*Split reflists* aim at solving this by separating reflists into 64
*buckets*. Package refs are sorted into individual buckets according to
the following system:

- Take the first 3 letters of the package name, after dropping a `lib`
  prefix. (Using only the first 3 letters will cause packages with
  similar prefixes to end up in the same bucket, under the assumption
  that packages with similar names tend to be updated together.)
- Take the 64-bit xxhash of these letters. (xxhash was chosen because it
  relatively good distribution across the individual bits, which is
  important for the next step.)
- Use the first 6 bits of the hash (range [0:63]) as an index into the
  buckets.

Once refs are placed in buckets, a sha256 digest of all the refs in the
bucket is taken. These buckets are then stored in the database, split
into roughly block-sized segments, and all the repositories and
snapshots simply store an array of bucket digests.

This approach means that *repositories and snapshots can share their
reflist buckets*. If a snapshot is taken of a repository, it will have
the same contents, so its split reflist will point to the same buckets
as the base repository, and only one copy of each bucket is stored in
the database. When some packages in the repository change, only the
buckets containing those packages will be modified; all the other
buckets will remain unchanged, and thus their contents will still be
shared. Later on, when these reflists are loaded, each bucket is only
loaded once, short-cutting loaded many megabytes of data. In effect,
split reflists are essentially copy-on-write, with only the changed
buckets stored individually.

Changing the disk format means that a migration needs to take place, so
that task is moved into the database cleanup step, which will migrate
reflists over to split reflists, as well as delete any unused reflist
buckets.

All the reflist tests are also changed to additionally test out split
reflists; although the internal logic is all shared (since buckets are,
themselves, just normal reflists), some special additions are needed to
have native versions of the various reflist helper methods.

In our tests, we've observed the following improvements:

- Memory usage during publish and database cleanup, with
  `GOMEMLIMIT=2GiB`, goes down from ~3.2GiB (larger than the memory
  limit!) to ~0.7GiB, a decrease of ~4.5x.
- Database size decreases from 1.3GB to 367MB.

*In my local tests*, publish times had also decreased down to mere
seconds but the same effect wasn't observed on the server, with the
times staying around the same. My suspicions are that this is due to I/O
performance: my local system is an M1 MBP, which almost certainly has
much faster disk speeds than our DigitalOcean block volumes. Split
reflists include a side effect of requiring more random accesses from
reading all the buckets by their keys, so if your random I/O
performance is slower, it might cancel out the benefits. That being
said, even in that case, the memory usage and database size advantages
still persist.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2025-02-15 23:49:21 +01:00
André Roth
8546cf31ce add test: snapshot empty mirror 2025-01-11 20:00:42 +01:00
André Roth
5a18428666 aptly.conf: fix s3 example 2025-01-11 15:25:53 +01:00
Gordian Schoenherr
8830354027 Extend system tests for @file filter syntax 2024-12-20 10:59:29 +09:00
Gordian Schoenherr
2467674fca Update system tests 2024-12-19 16:05:21 +09:00
André Roth
93650efddb Merge pull request #1404 from schoenherrg/fix/with-sources-ignored
Fix `-with-sources` not fetching differently named source packages
2024-12-11 13:01:30 +01:00
André Roth
e50a5e175f update documentation and man page 2024-12-11 12:02:52 +01:00
André Roth
a7d6782176 add test and improve config error messages 2024-12-11 12:02:52 +01:00
André Roth
a15d8a3f7b add test 2024-12-11 12:02:52 +01:00
André Roth
4e566b4692 fix tests and lint 2024-12-11 12:02:52 +01:00
André Roth
e92afd8f78 fix unit tests on arm
and fix etcd data dir
2024-12-11 10:40:44 +01:00
André Roth
280563caa8 unit-tests: allow running as user 2024-12-11 10:40:44 +01:00
André Roth
09c56342d2 fix json 2024-12-11 10:40:44 +01:00
André Roth
ea80f6d49c write commented json default config 2024-12-11 10:40:44 +01:00
André Roth
1f469e23b5 fix optional params 2024-12-11 10:40:44 +01:00
André Roth
5e91b10c8c improve test to check for source pkgs with different name 2024-12-11 05:33:38 +01:00
Gordian Schoenherr
8c3fe8dabb Fix failing system test
The fix of the -with-filter flag causes the following previously
missing source files to be downloaded, so I updated the test file.

```
rkward_0.7.5-1~bullseyecran.0.debian.tar.xz
rkward_0.7.5-1~bullseyecran.0.dsc
rkward_0.7.5.orig.tar.gz
rpy2_3.5.12-1~bullseyecran.0.debian.tar.xz
rpy2_3.5.12-1~bullseyecran.0.dsc
rpy2_3.5.12.orig.tar.gz
```
2024-12-10 11:52:55 +09:00
André Roth
320307f504 graph: do not remove tempfile when opening in viewer 2024-12-04 17:30:27 +01:00
André Roth
d80b905945 run azure tests in docker 2024-11-17 17:44:31 +01:00
André Roth
d96ef0f178 Merge pull request #1393 from aptly-dev/improve/debianization
Improve/debianization
2024-11-17 17:38:47 +01:00
André Roth
d2b9adf6f2 Add a test to confirm that skel files added with the same path as a repository file do not override the repository file.
Co-authored-by: iofq <cjriddz@protonmail.com>
2024-11-17 14:17:14 +01:00
André Roth
53c2f8b778 debian: add lintian
and fix/improve cross building. build now with PIE and RELRO
2024-11-17 14:10:30 +01:00
Mauro Regli
1357d246d8 rename addon files to skel files 2024-11-17 14:09:37 +01:00
Mauro Regli
03f189b62c add first test of addon files 2024-11-17 14:09:37 +01:00
André Roth
c86b888b0a add tests 2024-11-08 19:00:18 +01:00
André Roth
596f59d3c4 fix tests 2024-11-08 17:07:37 +01:00
André Roth
19d213d748 fix tests 2024-11-08 15:55:01 +01:00
André Roth
dd4f90e4c2 Revert "use git-lfs for test files"
This reverts commit bf4b660568.
2024-11-08 15:23:31 +01:00
André Roth
38485a5b1e add test 2024-11-07 17:07:37 +01:00
André Roth
bf4b660568 use git-lfs for test files 2024-11-07 17:07:37 +01:00
André Roth
a4c53689ca docker-wrapper: ignore root user
some systems (MacOS) might have root permissions on the volume directories.
2024-11-01 20:18:05 +01:00
André Roth
0ceff44421 improve log 2024-11-01 20:01:45 +01:00
Christoph Fiehe
c9309c926c Command to replace the whole staged source list added.
Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-11-01 17:48:03 +01:00
André Roth
ee3124cfc6 update bash completion 2024-11-01 17:48:03 +01:00
Christoph Fiehe
f8f28e9554 Fixing tests and fix cleanup.
Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-10-22 16:58:15 +02:00
Christoph Fiehe
d87d8bac92 Fix test cases.
Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-10-22 16:58:15 +02:00
Christoph Fiehe
9dffe791ad Restoring original test sequence
Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-10-22 16:58:15 +02:00
Christoph Fiehe
3057aed571 Test cases added.
Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-10-22 16:58:15 +02:00
Christoph Fiehe
14c29ff912 Fixing tests.
Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-10-22 16:58:15 +02:00
Christoph Fiehe
bd64232eb6 Allow management of components
This commit allows to add, remove and update components of published repositories without the need to recreate them.

Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
2024-10-22 16:58:15 +02:00
André Roth
8ddb81eb5c Merge pull request #1368 from aptly-dev/fix/repo-add-errmsg
repo add: improve error message
2024-10-22 16:39:45 +02:00
André Roth
0666f8784f repo from snapshot: add negative test 2024-10-22 11:13:31 +02:00
Андрей Лухнов
f8e0a8d880 Update create repo API to support snapshots
To achieve feature parity with cli, it is now possible
to create repos from snapshots
2024-10-22 07:53:43 +03:00
André Roth
75ca51b23b improve error message 2024-10-10 12:03:13 +02:00
André Roth
861260198a publish: persist multidist flag 2024-10-08 22:28:12 +02:00
André Roth
14a343a0d7 system tests: support fitureCmds and allow dirmgr to startup
- fixes a race condition, where dirmgr does not seem to  be ready
- imports secret key for signing if gpg2 is used
2024-10-08 15:38:42 +02:00
André Roth
704af8f2f0 docker: use bash shell for aptly user 2024-10-08 02:14:30 +02:00
André Roth
df18133179 fix system test
fixture commands are actually executing ./aptly-test, do the same here
2024-10-08 01:22:10 +02:00
André Roth
a998755245 debian: fix dependencies
- docker: install more tools
2024-10-08 01:22:10 +02:00
André Roth
98c82a3684 improve Makefile
- simplify Makefile
- improve devserver
- improve make clean
2024-10-08 01:22:10 +02:00