Open olehmisar opened 5 months ago
the cause is @aztec/bb.js
package because it exports a 63.6mb file "dest/browser/index.js". It got bigger in version 0.35.0.
0.34.0 - 23.3mb 0.35.0 - 61mb 0.40.1 - 63.6mb
Thanks, duly noted. This is indeed not ideal, we should put this larger debug-symbols-included version in another package but have not yet. Meanwhile, can you let us know how much RAM you have?
16gb. If i allow nodejs to use more memory via NODE_OPTIONS=--max_old_space_size=16384
, it builds fine. The problem is that it cannot be build on servers like netlify, vercel etc.
Thanks makes sense, helpful to know. I see someone was actually able to resolve such an issue on vercel https://github.com/sveltejs/kit/issues/4795 wonder if you can set it in build step, but limited context so sorry if already tried
Hi there! Just wanted to see if we had to do something here or if the setting could be applied in vercel (our preference for now). Were you able to try this?
@ludamad is it time to reduce bb.js size? More and more people are stumbling upon this issue
It is now done, will be in next release
... or it was in but strangely broke things, hopefully will be able to investigate why soon
btw, are you gonna keep BarretenbergSync
around?
It does not play well with browsers because the whole aztec.js sdk depends on BarretenbergSync and something as simple as import { createPXEClient } from "@aztec/aztec.js"
will block the whole execution graph until all wasm is fetched and executed. But it does not make sense because createPXEClient
does not even use wasm.
@olehmisar as per our chat on discord DMs, could you confirm if increasing ram given to node in vercel fixed the build error
@rahul-kothari no, not fixed. As per comment above it still fails to build on vercel. Looks like vercel does not allow increasing RAM. Same thing with netlify. Increasing RAM only works locally.
https://github.com/AztecProtocol/aztec-packages/issues/6527#issuecomment-2122770230
Are you not able to change the build command Vercel runs? Does it not just do a yarn/npm build so you can fix like the command above that worked for svelte?
@ludamad
NODE_OPTIONS=--max_old_space_size=16384
flag. Or vercel/netlify VPS just does not have 16gb of memory.You can try deploying this repro on vercel to see yourself https://github.com/ShieldSwap/aztec-build-out-of-memory-repro
I didn't say it was svelte specific, I was giving an example that seemingly resolved it. We are not committed to supporting less than 16gb of RAM at this time so would appreciate if you could investigate more on vite side
On Mon, Sep 30, 2024, 4:39 PM oleh @.***> wrote:
@ludamad https://github.com/ludamad
- I can change the build command. But vercel/netlify just ignores NODE_OPTIONS=--max_old_space_size=16384 flag. Or vercel/netlify VPS just does not have 16gb of memory.
- It's not sveltekit specific, it's vite specific.
You can try deploying this repro on vercel to see yourself https://github.com/ShieldSwap/aztec-build-out-of-memory-repro
— Reply to this email directly, view it on GitHub https://github.com/AztecProtocol/aztec-packages/issues/6527#issuecomment-2384104387, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABIBGJF5AMUVVVP764Z6LLZZGZIFAVCNFSM6AAAAABH5KEIN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBUGEYDIMZYG4 . You are receiving this because you were mentioned.Message ID: @.***>
@ludamad there is nothing to investigate. Vite uses rollup under the hood. Rollup crashes during build because it tries to load bb.js into RAM. Vercel/Netlify do not allow increasing memory during build time, so if you are not committed to supporting less than 16gb of RAM, then nobody will be able to deploy to Vercel/Netlify if they are using vite.
It affects not only Aztec but Noir as well(because Noir uses bb.js to prove).
The issue from svelte that you linked is marked as "completed" but it's not solving anything. They just marked it as duplicate of https://github.com/vitejs/vite/issues/2433 (which is still open)
Gotcha. It seems the hobby plans just have 1GB RAM, I will take a look sometime
@ludamad i believe you should avoid bundling WASM as an inline base64 url string. That's where the problem is. But not sure about Vite support of .wasm imports. It's not straightforward either. Though situation
Meanwhile, I created a vite plugin that fixes bb.js by importing it from unpkg in production builds.
@ludamad could you please at least not minify the js bundle of bb.js? It would then be possible to patch bb.js in userland. Add this to webpack config of bb.js.
module.exports = {
//...
optimization: {
minimize: false,
},
};
Sorry is this related to the memory bug?
@ludamad yes it is. If users can patch bb.js, vite will be able to build. A temporary workaround for a very cheap price
Agree with @olehmisar! The @aztec/bb.js
package is huge!
Building this simple file with vite fails because of out of memory error:
This issue first started happening in 0.35.0. It still persists in 0.40.1.
Full repro: https://github.com/ShieldSwap/aztec-build-out-of-memory-repro Related vite issue: https://github.com/vitejs/vite/issues/2433
Error logs
```text vite build vite v5.2.11 building for production... transforming (1193) node_modules/asn1.js/lib/asn1.js <--- Last few GCs ---> [27246:0x120008000] 66734 ms: Scavenge 4031.0 (4095.6) -> 4030.7 (4106.6) MB, 10.58 / 0.00 ms (average mu = 0.365, current mu = 0.399) allocation failure; [27246:0x120008000] 66753 ms: Scavenge 4037.7 (4106.6) -> 4038.4 (4107.4) MB, 14.38 / 0.00 ms (average mu = 0.365, current mu = 0.399) allocation failure; [27246:0x120008000] 66773 ms: Scavenge 4038.5 (4107.4) -> 4037.6 (4130.4) MB, 20.54 / 0.00 ms (average mu = 0.365, current mu = 0.399) allocation failure; <--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x102ae20f0 node::Abort() [~/.nvm/versions/node/v20.8.1/bin/node] 2: 0x102ae22d8 node::ModifyCodeGenerationFromStrings(v8::Local