Commit Graph

27 Commits

Author SHA1 Message Date
Christopher Baines e39c9da028 Store the distribution of derivations related to packages
This might be generally useful, but I've been looking at it as it offers a way
to try and improve query performance when you want to select all the
derivations related to the packages for a revision.

The data looks like this (for a specified system and target):

┌───────┬───────┐
│ level │ count │
├───────┼───────┤
│    15 │     2 │
│    14 │     3 │
│    13 │     3 │
│    12 │     3 │
│    11 │    14 │
│    10 │    25 │
│     9 │    44 │
│     8 │    91 │
│     7 │  1084 │
│     6 │   311 │
│     5 │   432 │
│     4 │   515 │
│     3 │   548 │
│     2 │  2201 │
│     1 │ 21162 │
│     0 │ 22310 │
└───────┴───────┘

Level 0 reflects the number of packages. Level 1 is similar as you have all
the derivations for the package origins. The remaining levels contain less
packages since it's mostly just derivations involved in bootstrapping.

When using a recursive CTE to collect all the derivations, PostgreSQL assumes
that the each derivation has the same number of inputs, and this leads to a
large overestimation of the number of derivations per a revision. This in turn
can lead to PostgreSQL picking a slower way of running the query.

When it's known how many new derivations you should see at each level, it's
possible to inform PostgreSQL this by using LIMIT's at various points in the
query. This reassures the query planner that it's not going to be handling
lots of rows and helps it make better decisions about how to execute the
query.
2023-03-09 08:29:39 +00:00
Christopher Baines 7ae1c97b92 Drop the thread pool idle seconds
To hopefully bring down the memory usage from idle connections.
2022-11-24 12:37:45 +00:00
Christopher Baines d06230fcf4 Close postgresql connections when the thread pool thread is idle
I think the idle connections associated with idle threads are still taking up
memory, so especially now that you can configure an arbitrary number of
threads (and thus connections), I think it's good to close them regularly.
2022-10-23 11:28:37 +01:00
Christopher Baines ff77bbea7e Make it possible to increase the number of thread pool threads
And double the default to 16.
2022-10-02 15:08:18 +01:00
Christopher Baines 8e23d38660 Handle migrations and server startup better
The server part of the guix-data-service doesn't work great as a guix service,
since it often fails to start if the migrations take any time at all.

To address this, start the server before running the migrations, and serve the
pages that work without the database, plus a general 503 response. Once the
migrations have completed, switch to the normal behaviour.
2022-06-17 13:13:21 +01:00
Christopher Baines 8beab2511c Query substitutes for latest processed revisions periodically
This is a step towards having up to date substitute availability data.
2021-11-16 19:08:46 +00:00
Christopher Baines d1a2a7125c Fix a regression with running sqitch
Introduced in 0dc05982cd.
2021-07-11 12:40:48 +01:00
Christopher Baines b4188bda9d Run sqitch in the change mode
Since this rolls back migrations less, which is good when the rollback bit
isn't always implemented.
2021-07-04 10:43:13 +01:00
Christopher Baines 0dc05982cd Try to adapt the PostgreSQL paramstring to use with sqitch 2021-06-16 13:44:00 +01:00
Christopher Baines 3225766207 Make it easier to get to a repl 2020-10-10 13:44:37 +01:00
Christopher Baines 18b6dd9e6d Stop opening a PostgreSQL connection per request
This was good in that it avoided having to deal with long running connections,
but it probably takes some time to open the connection, and these changes are
a step towards offloading the PostgreSQL queries to other threads, so they
don't block the threads for fibers.
2020-10-03 09:22:29 +01:00
Christopher Baines a0263a0eae Set a statement timeout of 60 seconds for web requests
This will help stop queries running for an unnecessarily long time, longer
than NGinx will wait for example.
2020-04-24 09:00:20 +01:00
Christopher Baines ded4df6632 Move and improve the "starting the server" message
Move it after the output relating to narinfo signing, and include the host.
2020-03-14 13:14:29 +00:00
Christopher Baines a03e1601de Improve handling of errors
Adjust the previously unused error page code, and start to use it. Only show
the error if configured to do so, to avoid leaking secret information.
2020-03-14 12:46:02 +00:00
Christopher Baines 7342280ead Guard against failures when loading the narinfo signing public key 2019-12-26 10:49:14 +00:00
Christopher Baines 54b3d8d93a Fix the option alist element names for the narinfo signing key 2019-12-26 10:47:29 +00:00
Christopher Baines 66e886a6b4 Serve narinfo files for derivations 2019-12-26 09:34:43 +00:00
Christopher Baines 5663235048 Rework the builds and build_status tables as well as related code
Allow for build status information to be submitted by POST request. This
required some changes to the builds and build_status tables, as for example,
the Cuirass build id may not be available, and the derivation may not be know
yet, so just record the derivation file name.
2019-11-24 20:18:08 +00:00
Christopher Baines 977609c66e Rewrite localhost for sqitch
As this means that like psql, the unix socket will be used.
2019-10-01 19:03:34 +01:00
Christopher Baines 3df0b43146 Use line buffering for the input and output ports
As these are used for logging, which is done on a line by line basis. Remove
the now redundant calls to (force-output).
2019-06-17 18:09:10 +01:00
Christopher Baines 5323f24133 Add --port and --host as options to the guix-data-service 2019-06-13 19:06:53 +01:00
Christopher Baines bd292d6f57 Add an option to create a pid-file
This'll help the a service manager (like the shepherd) know when the service
is ready, which at the moment, means the database migrations have happened.
2019-06-11 07:40:26 +01:00
Christopher Baines cf5dace846 Change to the sqitch directory to run deploy
As this means it can find the relevant files.
2019-06-11 07:22:17 +01:00
Christopher Baines 93fdefc7b1 Pass the --db-client option to sqitch deploy
So that it can always find psql.
2019-06-11 07:15:01 +01:00
Christopher Baines d7586e88fa Pass --plan-file to the sqitch deploy command 2019-06-08 10:28:14 +01:00
Christopher Baines 42c608e004 Add a --update-database option
This runs Sqitch on startup, which should make managing the database easier,
as you just have to restart the service with this option, and the database
should be updated if necessary.
2019-06-07 07:33:34 +01:00
Christopher Baines 5a9262b38d
Initial commit
This is a service designed to provide information about Guix. At the
moment, this initial prototype gathers up information about packages,
the associated metadata and derivations.

The initial primary use case is to compare two different revisions of
Guix, detecting which packages are new, no longer present, updated or
otherwise different.

It's based on the Mumi project.

[1]: https://git.elephly.net/software/mumi.git
2019-02-07 22:26:57 +00:00