From: Vincent Ambo <mail@tazj•in>
To: sterni <sternenseemann@systemli•org>, depot@tvl.su
Subject: Re: [tvix] string contexts vs. reference scanning
Date: Wed, 11 Jan 2023 04:20:20 -0800 [thread overview]
Message-ID: <CANHrikrByzWKLLzh+amCkaBrZZg68EY05puZU6AGe2bDykQE+A@mail.gmail.com> (raw)
In-Reply-To: <ecb3ceb6-eb07-7e96-6aa3-28b4b640d445@systemli.org>
sterni <sternenseemann@systemli•org> writes:
> One thing I'd want to see answered is how to handle import from
> derivation.
Files enter an evaluation through the `EvalIO` interface, which is
passed the path(s) to read and returns the contents or store path.
In the actual implementation of `EvalIO` that supports store
interactions, store path access is detected and blocked/suspended until
build completion.
At the time that this calculation occurs, we already called
builtins.derivation or equivalent on the thing yielding that path, so
the build is already running.
> There are also similar occasions where things get realised while
> evaluating (interactively?) except reading / importing, but I don't have
> a very good handle on those yet.
I'm not sure what those would be, but there's nothing the evaluator can
do to read from disk that wouldn't go through EvalIO.
> 1. You can discard some using builtins.unsafeDiscardOutputDependency.
This doesn't really discard the context, it changes the _type_ of the
context entry. See cl/7807.
I believe that this is unnecessary, all uses of it in nixpkgs are a hack.
> My _unconfirmed_ theory is that this was a quick and easy workaround
> that was implemented without considering the underlying problem. In my
> view, there is no reason why `drvPath` should incur a reference to all
> outputs of the derivation as well as the derivation file itself (I
> think this is thanks to the reference scanner the store runs after the
> fact which determines if the derivation and/or any of its outputs are
> actually referenced).
Well, the drv file brings everything inside of it into scope (that
includes its output paths, which are part of the serialised
representation). Otherwise referencing a drv file would make "dead
paths" available in the builder.
It's conceptionally reasonable that this closure is yielded, I think. It
seems odd to me that it involves store database queries, though. All the
information should be *in* the drv file.
In Tvix, if a drv path is referenced then that drv was also part of the
evaluation, so we *should* already know all of that information without
running any queries.
> - To drop wrongfully retained string context. All string
> operations retain string context, even though some actually
> destroy any reference that was present in the string.
This is basically a workaround for how contexts work in C++ Nix. It's
not a problem if contexts are replaced by scanning.
> - As an escape hatch from references to the derivations in question.
> We use this in //nix/buildkite:
Yes, but we use it to work around a problem that we only have because of
the model of C++ Nix. In Tvix this whole thing would work differently
(the evalution itself drives the creation of the build targets).
We'd essentially have a buildkite-driver that uses Tvix to evaluate and
yields the build targets as necessary, using a store (local or remote)
as the synchronisation point.
The other uses are covered in https://cl.tvl.fyi/7807 and I think fairly
uncontroversial.
My gut feeling is that we can get away with not implementing any of the
destructive string context operations, and if we _really_ end up needing
unsafeDiscardStringContext, it's not terribly difficult to implement
(could be a `Value` variant containing another Value that just acts as a
marker).
//V
next prev parent reply other threads:[~2023-01-11 12:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CANHrikrEDPkH1raGDGAGETeATrWOJ=sBQCUXr6=pHJm1ajbd0A@mail.gmail.com>
[not found] ` <20221202152213.3a59e629@ostraka>
2023-01-09 22:07 ` Vincent Ambo
2023-01-11 11:49 ` sterni
2023-01-11 12:20 ` Vincent Ambo [this message]
2023-03-16 9:41 ` Vincent Ambo
2023-03-16 12:00 ` Florian Klink
2023-01-10 20:20 ` reference-scanning inputDrvs/inputSrcs Adam Joseph
2023-01-10 20:48 ` Vincent Ambo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANHrikrByzWKLLzh+amCkaBrZZg68EY05puZU6AGe2bDykQE+A@mail.gmail.com \
--to=mail@tazj$(echo .)in \
--cc=depot@tvl.su \
--cc=sternenseemann@systemli$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://code.tvl.fyi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).