Comments (4)
This is hard to support because the NAR file format puts the size of the file before its contents. So if we can't rely on the file size reported by lstat()
, we would have to read the entire file into memory first, which would be a problem for supporting large files.
Related: #10019
from nix.
I see. Here's a few thoughts I have on how this could theoretically be solved, note that I don't really know how feasible these are given that I'm not familiar with how Nix works internally:
- Read the file as we do now, but then attempt to continue reading. If this returns more data than expected, keep adding to the NAR file and then seek back to the beginning of the file, updating the size.
- This wouldn't work if the NAR file is created in a streaming fashion.
- Buffer the entire file into memory or a temporary file if and only if the filesystem reports a size of zero and a read call yields data.
- This would still break for filesystems that report a non-zero size that is smaller than the actual file size.
Some things to consider:
- What if the filesystem reports a size larger than the actual file? Would this lead to an invalid NAR file being generated, or an error being emitted? We may be able to employ a strategy similar to what I've first suggested above.
- How to handle infinitely large files? What should we do if someone attempts to use, for example,
/dev/random
? Should we have a hard limit on how large a file can be? Should we have this limit only for files that report a zero-size?
from nix.
Triaged in Nix team meeting:
-
@roberth: we could special-case the 0. if the size is reported as 0, we could still try reading it and buffer it.
- @edolstra: at least that would work. wonder what POSIX has to say what should happen if the file size is not reported correctly (these files do exist, such as
/proc
)
- @edolstra: at least that would work. wonder what POSIX has to say what should happen if the file size is not reported correctly (these files do exist, such as
-
@edolstra: we used to buffer essentially entire files in memory, but that simply doesn't scale
- it could be done, but it's hard to do in constant-space memory
-
This wouldn't work if the NAR file is created in a streaming fashion.
@Ericson2314: It is created in a streaming fashion, we wish to use constant space and often create NARs directly into a sink like a pipe or socket.
-
This mismatch between actual file size and reported file size is considered absolutely legal under Linux (citation needed)
@Ericson2314: We would love to see that citation :)
from nix.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2024-05-15-nix-team-meeting-minutes-146/45491/1
from nix.
Related Issues (20)
- Tar download very slow HOT 5
- Should `--commit-lockfile-summary` be renamed to `--commit-lock-file-summary`?
- Virtual path semantics that are deterministic, lazy and suitable for performing deduplication of values by a path value key. HOT 2
- Can't create sym link '/etc/tmpfiles.d/nix-daemon.conf' HOT 3
- Stability promise, reprodubility properties HOT 2
- explain cache misses HOT 6
- Move examples in classic commands closer to the top
- Tools to update ssl ca break HOT 2
- flakes: input is updated on upgrade if repo owner capitalization is changed HOT 4
- {extra-,}experimental-features in flake nixConfig ignored HOT 2
- Nested block comments HOT 8
- Update xmonad to 0.18.0 HOT 2
- builtins.fetchGit fails with .gitmodules entries that aren't submodules HOT 2
- Recursion in `builders` definitions deadlocks builds with `waiting for lock on '/nix/store/...'` HOT 5
- Investigate using FUSE HOT 1
- nixos.org is out of date wrt latest Nix release HOT 3
- dont ignore the CFLAGS from pkg-config check for libseccomp. HOT 4
- Darwin installer: create a case sensitive APFS volume HOT 4
- run nix in a non root container in openshift - restricted SCC HOT 5
- `nix build` breaks inside `nix develop`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nix.