Commit Graph
17624 Commits
Author SHA1 Message Date
alois31andGerrit Code Review 3df901e6ed Merge changes Ic91ca404,I142cf38f into main
* changes:
  libmain/progress-bar: implement synchronized updates
  libmain/progress-bar: fix writeToStdout in multiline mode
2025-03-09 17:17:58 +00:00
Alois Wohlschlager a13521bb1f libmain/progress-bar: implement synchronized updates
If tearing occurs while the progress bar is rendering, flickering can occur.
This is particularly visible in multiline mode. Use the synchronized updates
specification [1] to make updates atomic on supported terminal emulators. On
unsupported terminals, the escape sequences should be ignored, leaving the
behaviour effectively unchanged (but there's nothing we could do better in this
situation).

[1] https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec

Change-Id: Ic91ca40422c73ac9f9e088c7cb78c1b8c28adc4e
2025-03-09 16:36:02 +01:00
Alois Wohlschlager 0b2d58a925 libmain/progress-bar: fix writeToStdout in multiline mode
The multiline progress bar would not clear itself before writing to stdout,
leading to interference with the redraw; the most visible symptom is after
building in the repl, where the lines indicating the build outputs would be
wiped instead of the progress bar header. Separate the steps of erasing and
redrawing the progress bar, so that arbitrary output can happen in between in
a non-awkward way. In addition to fixing the bug, the code is simplified.

Change-Id: I142cf38f5ba5cd672cd6016e996b2f7bf726e9cd
2025-03-09 16:36:01 +01:00
eldritch horrors bba678e5c5 libstore: don't use curl decompression support
it's broken with http2 and transfer flow control. cf fj#662

Change-Id: Iaf6312bfcefa18d168faef47f57481199dd30b8d
2025-03-08 20:58:34 +01:00
eldritch horrors 93c3ca4e92 libutil: fix async copyNAR failing on slow io
well, oops. on slow io (as can happen with ssh remote builders) we could
have extended a nar read buffer past what was actually read, injecting a
span of zeroes into the read buffer where we requested some data but got
a partial result instead. also add some tests that would've caught this.

Change-Id: I67aa06b4715aeec6a5bdacaafa9b79849e664e2f
2025-03-07 15:45:51 +01:00
eldritch horrors 0f3aba83c5 tests: turn off unit test verbosity
there's no real usefulness to this output in build logs. in interactive
development builds -v can be passed to meson to restore the old output.

Change-Id: Iac4c0573fd1cac5fc9044b950ef52ee50448e6fc
2025-03-07 15:44:42 +01:00
eldritch horrors f61bcc6ca9 libstore: turn LocalStore::dbPool into a mutex
this reverts commit 749a323597. the pool
does hurt performance and concurreny, so let's revert now that we can.

Change-Id: I0b154cf04d14fa2cb4d2028f9cc865e463cd2265
2025-03-05 23:07:20 +01:00
eldritch horrors 166860fbc6 libsture: use processGraphAsync in Store
processGraph is not fully async-safe because it cannot yield, ever.

Change-Id: I1c988bc5113303a8a31a6f96c6edc08a9d73c336
2025-03-05 23:07:20 +01:00
eldritch horrors 4e266a25d6 libutil/libstore: asyncify Pool
connection pools of remote stores can currently block. this is not a
problem when each request runs on a dedicated thread, but with async
code this is no longer true. if a remote store has exhausted all its
available connections on one executor and another job starts *on the
same executor* we'll deadlock if that job makes another remote store
request. unlike with sqlite previously it's not reasonable, not even
necessary, to make the pools unbounded: since we use pools only with
remote stores we can asyncify all of them at once, and since they're
leaves of all call stacks we do not have much code to change either.

Change-Id: I8c457e27893e22c2cfc35933307a5283c986805a
2025-03-05 23:07:20 +01:00
eldritch horrors 2a1a78c025 libstore: turn Store::state into an async mutex
Change-Id: I9192203e036ee24cac09ed14f7a343a9595ebe70
2025-03-05 18:49:45 +01:00
eldritch horrors 3fc07e38c7 libstore: asyncify Store::getStats
nothing uses this at the moment, but we may as well keep it.

Change-Id: I9e0061fb03e0371f83071d08e6dba1275c727226
2025-03-05 18:49:45 +01:00
eldritch horrors c72d057ee3 libstore: asyncify LocalStore::invalidatePath
Change-Id: I9dc8704b183a48c10d5dfd211aac621764e0a483
2025-03-05 18:49:45 +01:00
eldritch horrors 81d5528646 libstore: asyncify Store::queryPathInfo{,Uncached}
Change-Id: I182c396ec0bfdfc8febd6752774e668b3d97dcc1
2025-03-05 18:49:45 +01:00
eldritch horrors 09727e15c5 libstore: asyncify Store::isValidPathUncached
Change-Id: I5a2df380490325282768b2edbe42656ffe40d10e
2025-03-05 18:49:45 +01:00
eldritch horrors 90caba8489 libstore: asyncify Store::isValidPath
Change-Id: I2b98781c04944282fd1219cbec0804fd1ceb6765
2025-03-05 18:49:45 +01:00
eldritch horrors fb2a808604 libstore: asyncify Store::narFromPath
Change-Id: Ia231b83d58adcf52fe1ba107a0eefea8111528df
2025-03-05 18:49:45 +01:00
eldritch horrors d3e435b2b9 libstore: asyncify BinaryCacheStore::writeNarInfo
Change-Id: Iad36b9541876a6a66030db357104ed189b45c4f0
2025-03-05 18:49:45 +01:00
eldritch horrors a29e3a4a58 libstore: asyncify FSAccessor, listNar
Change-Id: I804ac18c4b6b80699247bb885493056799bf3d0c
2025-03-05 18:49:45 +01:00
eldritch horrors 19b8502ced libstore: asyncify Store::read{,Invalid}Derivation
Change-Id: Id1af47e5f35ea81ede9c47dba8f50045a2b9bde2
2025-03-05 18:49:45 +01:00
eldritch horrors f6ce58ac72 libstore: asyncify hashDerivationModulo
Change-Id: I15285a5b833799c3e23e44229a28a7af1bcb3e8a
2025-03-05 18:49:45 +01:00
eldritch horrors f43dbf3035 libstore: asyncify Derivation::checkInvariants
Change-Id: I269d5d11af811e4ab2f099fdc4e1c56597f38678
2025-03-05 18:49:45 +01:00
eldritch horrors 9d52d0db79 libstore: asyncify LocalStore::addValidPath
Change-Id: Iada9f7647b6913d267b061421d7b3d7b1bed8343
2025-03-05 18:49:45 +01:00
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