Commit Graph
17602 Commits
Author SHA1 Message Date
eldritch horrors fc0bea42c2 libstore: asyncify staticOutputHashes
Change-Id: Idb0daa96021656258c8018bb47cdf3c77871be0d
2025-03-05 18:49:45 +01:00
eldritch horrors 03ab0fcb53 libstore: asyncify Store::queryRealisation{,Uncached}
Change-Id: I4c4d75c773493fcd63c131e30a2e4d6ec5d230ac
2025-03-05 18:49:45 +01:00
eldritch horrors e057497f3e libstore: asyncify LocalStore::invalidatePathChecked
Change-Id: I425b155e98d4d85f6d2f91841cbb8725e195a607
2025-03-05 18:49:45 +01:00
eldritch horrors d5d498ab22 libstore: asyncify Store::queryReferrers
Change-Id: Iec5c85a22738f1a427774936d369e5f30af1a8a5
2025-03-05 18:49:45 +01:00
eldritch horrors 85cd558b6d libstore: asyncify Store::queryValidDerivers
Change-Id: I9ac447cb57e0ba330eee216280eb3d7913c5782b
2025-03-05 18:49:45 +01:00
eldritch horrors ab750b26f8 libstore: asyncify Store::queryAllValidPaths
Change-Id: I2c38669fd061d1b34a659db4c821be8a69a6835c
2025-03-05 18:49:45 +01:00
eldritch horrors c9eeef1a50 libstore: asyncify Store::addSignatures
Change-Id: If5fac14c9b5c8e7c9605080606f147979cc3ca31
2025-03-05 18:49:45 +01:00
eldritch horrors 3e5baa4e9e libstore: asyncify Store::queryStaticPartialDerivationOutputMap
Change-Id: Iba6dd8197a51c43f7d38d7b15b153c5acd0c7f5b
2025-03-05 18:49:45 +01:00
eldritch horrors 52ce659bd3 libstore: asyncify LocalStore::registerValidPath{,s}
Change-Id: I464d1ad1a7ab869953ca86016bb47ee946a6cd1b
2025-03-05 18:49:45 +01:00
eldritch horrors 3fe2be1bcf libstore: asyncify Store::queryPathFromHashPart
Change-Id: I7ba33a0a27542350f4b89ce1cfe0afbd39134bce
2025-03-05 18:49:45 +01:00
eldritch horrors 7d9fad0cf1 libstore: asyncify Store::registerDrvOutput
Change-Id: Ib8ba14ba2ce210714181dbb85ca8a42480a32c55
2025-03-05 18:49:45 +01:00
eldritch horrors 749a323597 libstore: turn LocalStore::_dbState into a pool
this is a connection pool of size 1. it's also extremely in the way of
making store methods async since all methods are necessarily entangled
with all other methods via this blocking connection pool. we also will
not be able to convert *all* public methods to async code at once (not
without losing what little remains of our sanity, anyway). we'll treat
the connection pool as unbounded for a while, until the conversion has
been completed. if it turns out to be too expensive to keep db handles
in a pool like this we can tune it back down to small, or even size 1.

Change-Id: I0f3adb66df6f45a84e480c090d6627a368917db5
2025-03-05 18:49:45 +01:00
eldritch horrors d5de4bc4fc libutil: add processGraphAsync
processGraph is not always safe to use in async code, but whether that's
the case depends on whether the caller is holding locks or not. (-sigh-)

Change-Id: Ieecea9c6d3c6abae222332bc6e3869bfd97631dd
2025-03-05 18:49:45 +01:00
eldritch horrors 32bb2b1b5b libutil: asyncSpread
this could be a method of AsyncCollect, but putting there would require
another overload that synthesizes the empty key types we use here. even
then a separate function is slightly nicer because it spares us writing
things like `asyncCollect(someIterableOfPromises).collect()` or similar

Change-Id: Ia92abc105016414a2171e237f2a0bc6233d3ccbf
2025-03-05 18:49:45 +01:00
eldritch horrors df7e63427d libutil: add topoSortAsync
Change-Id: Icad14f3e168f9577e7b99ac5f3f552f8625aebcd
2025-03-05 17:34:25 +01:00
eldritch horrors 234fff5afc libstore: split LocalStore constructor
more precisely, split it into store preparation (which remains in the
constructor proper), db initialization, and prepared statements init.
this will let us more easily turn the dbState into a connection pool.

Change-Id: I894acd4553bc83a2d86229922b757c573e394cac
2025-03-05 17:34:25 +01:00
eldritch horrors 549f385d40 libstore: drastically shorten sqlite busy timeout
this is one of the cases retrySQLite is supposed to handle. with busy
timeouts set at the connection level we may instead wait for up to an
hour to acquire locks before actually falling back to the retrySQLite
loop, blocking an entire thread in the process. this isn't painful in
the current system that uses dedicated threads for everything, but an
async executor actually suffers. since we use sqlite in WAL mode, and
WAL mode still allows reads to happen concurrently with writes, we'll
want to not block an executor on sqlite write locks. (note that while
we do have a mutex around db access that mutex is only held inside of
retrySQLite callbacks, so it will be released where we'd block today)

do note that we don't disable the timeout completely since that could
drastically reduce write performance. multiple daemon processes using
the same database file will naturally conflict, but each write is not
usually that expensive. going to sleep immediately instead of waiting
a bit can greatly impact throughput. waiting for 50ms should be fine.

Change-Id: I2d8e36ed7a0183bbc213490ebde2c79fc6e2f4b2
2025-03-05 17:34:25 +01:00
eldritch horrors 0bb0f43aae libutil: add AsyncMutex lock waits
this is like a condition variable associated with the mutex. it's all
we'll need for the async transition, so we don't add a separate type.

Change-Id: Id9aefadd3b50e5f14f7b4d6bad41721f5249ce59
2025-03-05 16:42:11 +01:00
eldritch horrors 4cabfee3d5 libstore: asyncify IndirectRootStore::addIndirectRoot
Change-Id: I369f3b8773c0e73737f2b44228c115b134edab19
2025-03-05 16:42:11 +01:00
eldritch horrors bbe450c3af libstore: asyncify Store::getVersion
Change-Id: Ia7ef0e577122f6754a73b2293855c6ae8cfa8457
2025-03-05 16:42:11 +01:00
eldritch horrors adf33551e4 libstore: asyncify Store::setOptions
Change-Id: I80d45ccdd027663a2b7c32f21a9a78fda6906044
2025-03-05 16:42:11 +01:00
eldritch horrors 4cd14a30bc libstore: asyncify Store::isTrustedClient
Change-Id: Iabf4aa6bf04e23179f03f5d0055560970809773e
2025-03-05 16:42:11 +01:00
eldritch horrors 12e9b8da0f libstore: asyncify Store::getProtocol
Change-Id: I52744d925d1239fd326a3ec4e3a26e8e8ca44be0
2025-03-05 16:42:11 +01:00
eldritch horrors a783d2c0d9 libstore: asyncify Store::connect
Change-Id: I6668295e228092754304ef63cda0b889bd82b198
2025-03-05 16:42:11 +01:00
eldritch horrors 87efae8a53 libstore: asyncify Store::queryMissing
Change-Id: I33cc483a3a60208dc2a2c99fa277738be356f5f2
2025-03-05 16:42:11 +01:00
K900 ca89e431a3 perl: drop version check
Meson started handling those differently[0], and Perl 5.8 is old enough
that anyone running an even older Perl is honestly asking for it.

[0]: https://github.com/mesonbuild/meson/commit/a3679a64eec7c312c81d657880f34f015426c7db

Change-Id: Ifba22e38a82abf4b6965dda0eed43a3064533d25
2025-03-04 13:09:01 +03:00
eldritch horrors 9cc7d18752 disable n-e-j test until it is fixed
ma27 said it's okay. this thing fails every other ci build because it's buggy.

Change-Id: Iecfd793c22b8721c2e59e105167637d72dc53cba
2025-03-03 23:34:40 +01:00
eldritch horrors 14067da947 libstore: pass async streams to Store::add{,Multiple}ToStore
Change-Id: Idafc0d640bf66d2d28ff71ae81546db8cf463ee2
2025-03-03 21:13:44 +01:00
eldritch horrors dc8a634d24 libstore: pass async streams to Store::addToStoreFromDump
Change-Id: I1b1f7a63f093e33b0f8387e61342615708875ba7
2025-03-03 20:48:59 +01:00
eldritch horrors 6ba538a66f libstore: pass async streams to RemoteStore::addCAToStore
Change-Id: I793ec08df8e48378f471c70bf1d3cddd70954d64
2025-03-03 20:48:59 +01:00
eldritch horrors eda550246b libstore: pass async streams to BinaryCacheStore::addToStoreCommon
Change-Id: I8f9dbaa46c3644fdacb59cee2d7249ff20c3bf92
2025-03-03 20:48:59 +01:00
eldritch horrors ffbd120dcf libutil: add an async writeFile
Change-Id: I062c07446be2b282dfec6c31c21805aac9f44ff4
2025-03-03 20:48:59 +01:00
eldritch horrors ef5573065c libutil: add an async restorePath
Change-Id: I9319f3dd3db454684259d2b324412fdad6dd8a64
2025-03-03 20:48:59 +01:00
eldritch horrors 66d515a3a2 libutil: add an async nar indexer
Change-Id: I4c22364c94e2bea1f18b835d9514c4c65a530c80
2025-03-03 20:48:59 +01:00
eldritch horrors 2367521008 libutil: add an async nar parser
sadly this is a visitor-only interface; async generators are not yet a
thing and preliminary benchmarks say that overhead would be too large.

Change-Id: I0460d18eba94441cf3101d46bfffdb69cdda81d1
2025-03-03 20:48:59 +01:00
eldritch horrors 18a24393e8 libutil: add an async copyNAR overload
Change-Id: I046ff704a2d2cb5115f7bf610feac3ed3247d992
2025-03-03 20:48:59 +01:00
eldritch horrors eafc75b9e9 libutil: handle nar header in Parser as well
that'll make adding more Parser users a lot easier.

Change-Id: I88032d84b178c67896e930e275b9affe1e46ba83
2025-03-03 20:48:59 +01:00
eldritch horrors 99bc932196 libutil: add an async io header
we'll need all of these before long. we're so, so sorry.

Change-Id: I7baab54cf8a112b74d52e3a53f82836bd9f7cb83
2025-03-03 20:48:59 +01:00
eldritch horrors 3844e34053 libutil: add box_ptr<T>::take
sometimes it's useful to turn a box into a unique_ptr. let's have that.

Change-Id: I3d142c6e157c5e61c16f3953b3b8b4cd616f0e93
2025-03-03 20:48:59 +01:00
eldritch horrors bcea854b1f libstore: use nar_index in BinaryCacheStore::addToStoreCommon
we could have constructed a nar accessor from an index just as well, but
we don't need any of the advanced accessor features like retrieving file
contents or full path-string based access to the archive. using an index
directly is simpler and faster, although in practice we shouldn't notice

Change-Id: Ic521536cd89e88cbe5aba4f26bf40f0c40d09341
2025-03-03 20:48:59 +01:00
eldritch horrors 7160096a51 libstore: add a toJSON for nar indices
this lives with the NarAccessor (for now) because only the nar accessor
consumes this format in-tree, and produces the same format for a second
type of data source (an FSAccessor instead of a precomputed nar index).

Change-Id: I54cddcf59a4e0501b5cc296c606f063feee5fb3b
2025-03-03 20:48:59 +01:00
eldritch horrors 4bcc9fc0bb libstore: use new indexer in NarAccessor
Change-Id: Id8f33d19aa33d6ff2ccad4469b052f8834b3547f
2025-03-03 20:48:59 +01:00
eldritch horrors 0d81e81dd1 libutil: add a nar indexer
we'll use this in NarAccessor to provide actually safe indexing of
archives. NarAccessor currently is not fully correct: it relies on
the parser not buffering anything to produce correct file offsets,
but only the nar implementation itself can reasonably expect that.

Change-Id: I64f300b86d8844b876a3ace723546ea7d7b4628b
2025-03-03 20:48:59 +01:00
Maximilian BoschandGerrit Code Review 18975fa016 Merge "libexpr: improve error reporting if NIX_PATH item cannot be downloaded" into main 2025-03-03 08:43:54 +00:00
eldritch horrors 201c0d5b7f libstore: more explicitly discard uninteresting nar
this wasn't fully correct to begin with; if restorePath threw an
exception we would not have discarded the nar, but if deletePath
threw an exception we would have. discarding the nar in this way
also lets us not swallow nar parser exceptions when adding a nar
for a valid path, potentially notifying clients of corruption in
their own data sources. ideally we would never read the nar when
we're not interested anyway, but that needs a new wire protocol.

Change-Id: Ie5e10a9bee05b67ec2adb9c4f7c9319a4e644e31
2025-03-03 03:04:49 +01:00
eldritch horrors 338f624220 libstore: simplify Store::addToStoreSlow
the web of sinks and sources is really convoluted. all we want to do is
to always write the full path dump into narHashSink, also write the nar
(during recursive import) or only file data (during flat import) into a
dedicate non-sha256 hash sink, and maybe check that the path was a file
(when doing flat imports). the graphviz diagram did not improve things.

Change-Id: I2d036358a78963222da3db885cf6971e51369344
2025-03-03 03:04:49 +01:00
eldritch horrors f039abeb64 libutil: make direct nar dumping public
ma27 asked for it, for hydra reason. where's heracles when you need him?

Change-Id: I15719a97a037dbe8b0d4d2ec89191597857e2a0f
2025-03-03 03:04:49 +01:00
eldritch horrors 446e22323e libstore: pass around prepared dumps, not paths and filters
this fully decouples the possibly-never-async bits of dumping from the
generation of dump bitstream. having the two separate will allow us to
change store import methods to use async streams, not our sync sources

Change-Id: I9dbd5e30ad3ee380c244b4a3760c11e37db3895f
2025-03-03 03:04:49 +01:00
eldritch horrors 4af06b2717 libutil: split path dumping and filtering
filtering of paths may call into nixlang code, and in turn may call into
the async runtime. dumps and dump preparations should thus be considered
never-async, but we can't mark them as such yet because async methods do
call them without issue at time of writing. we cannot mark them as such;
only a single function in libexpr may cause such problems. fetchers also
use dumpPath with filters, but those filters never call into async code.

Change-Id: Ica0bd853419e08cd5b0f7926820e3c5a8d0f4688
2025-03-03 02:02:49 +00:00
eldritch horrors 3bf0dcaef3 libstore: split fetchToStore
only a single caller uses flat fetching at all. it still makes sense to
not inline that single caller for now, mostly due to activity reporting

Change-Id: I1a6420868443c3a684deafc7a4f567d4d4b1bd53
2025-03-03 02:02:49 +00:00