-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tea consuming RAM in proportion to download size #338
Comments
hmm. I wonder if our download code uses too much RAM? We stream the bytes to a file so we shouldn't be keeping around a large buffer. But I imagine RAM is a tight constraint, and certainly OoM (out of memory) is a killable offense. /cc @jhheider |
I'll be happy to see if that is a known issue with codespaces (I can also try a higher RAM codespace) |
On a higher ram (4 GB to 8 GB) code space, the installation was successful. Thanks! |
Reopening because seemingly we are consuming RAM in proportion to download size. Potentially this is not working as we expect. |
I would say this doesn't have the smell of a streamable interface. The newer SubtleCrypto-based API looks like it'll take iterable BufferSources, but some algorithms require being able to inspect the whole object at once (though I suspect SHA256 isn't one of those). Still, it might stream data in, but I wouldn't be surprised if it keeps it, and, if the algorithm requires it, it must. |
this suggests sha256 is streamable. |
Sha256 is streamable. It looks like if ((data as AsyncIterable<BufferSource>)[Symbol.asyncIterator]) {
const wasmCrypto = instantiateWasm();
const context = new wasmCrypto.DigestContext(name);
for await (const chunk of data as AsyncIterable<BufferSource>) {
const chunkBytes = bufferSourceBytes(chunk);
if (!chunkBytes) {
throw new TypeError("data contained chunk of the wrong type");
}
context.update(chunkBytes);
}
return context.digestAndDrop(length).buffer;
} |
It would probably require a refactor of the code but I think that makes sense in the short term. In the long term, if w3c/webcrypto#73 gets addressed, we may get a native solution to this. By the time that gets merged and implemented though I wouldn't be surprised if tea moved to rust. |
This just bit me today while trying to use clang inside a vm with 4 gigs of memory. This is very painful. I will open a PR soon with the refactor of useDownload. |
Perhaps an off topic question, but why would tea move to rust? |
tea +rust-lang.org
"Killed" in Github Codespaces
@mteam88 the two reasons are binary size and performance. The only performance issue we are likely to not be able to solve with TypeScript/deno is startup time. If that can be solved then likely we won’t have any real concerns. We could always write some pieces in rust and bind them in if there are any specific sections of code that would benefit. The binary size is less likely to be solved (I think, correct me if wrong). Currently we are ~90MB uncompressed. It's true that nowadays this is less an issue in general. But:
Provided deno can mitigate these then we probably wouldn't switch. I love TypeScript and deno both. |
@mxcl thanks. That makes a ton of sense |
There's also the fact that writing everything in rust takes 10 times as long, but it basically can't crash if it compiles[citation needed]. It's why rust programmers have such high language satisfaction. That and masochism. |
😅 I think this is the concept, but unfortunately due to the aforementioned increase in dev time it is quite common to take shortcuts to get things done faster (in an unsafe manner). Unfortunately see this a lot in OSS. I am a big fan of the current plan of (nailing down the api with deno) -> (rewrite in rust) though. Seems to capture the best of both worlds. |
Oh, sure. You can choose to balance dev time vs. safety. Similar to |
When I run
tea +rust-lang.org
on a fresh Codespace, the command seems to begin installation, but then gets killed. This may be a problem with codespaces, but if it is, I have never seen it before.Regular rust installation works fine in codespaces.
It seems that llvm.org installation gets to 31% or so and then is
Killed
The text was updated successfully, but these errors were encountered: