softprops / serverless-rust

⚡ 🦀 a serverless framework plugin for rustlang applications
https://www.npmjs.com/package/serverless-rust
MIT License
541 stars 81 forks source link

Out of memory while packaging for local invocation #67

Closed sebasmagri closed 4 years ago

sebasmagri commented 4 years ago

🐛 Bug description

When packaging a service for local invocation, serverless runs out of heap memory and aborts.

🤔 Expected Behavior

Local invocation should work

👟 Steps to reproduce

Serverless: Packaging service...

<--- Last few GCs --->

[3279482:0x358dce0]    61396 ms: Scavenge 1179.7 (1438.5) -> 1171.1 (1443.0) MB, 7.9 / 0.0 ms  (average mu = 0.216, current mu = 0.111) allocation failure 
[3279482:0x358dce0]    62094 ms: Mark-sweep 1185.0 (1443.0) -> 1174.0 (1438.5) MB, 661.8 / 1.3 ms  (average mu = 0.189, current mu = 0.158) allocation failure scavenge might not succeed
[3279482:0x358dce0]    62161 ms: Scavenge 1187.0 (1438.5) -> 1176.8 (1441.5) MB, 8.3 / 0.0 ms  (average mu = 0.189, current mu = 0.158) allocation failure 

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x51e71dbe1d]
Security context: 0x343572c1e6e9 <JSObject>
    1: _process [0x918c3b77bb9] [/home/smag/.config/yarn/global/node_modules/glob/glob.js:~298] [pc=0x51e726b2c9](this=0x3fb631002201 <Glob map = 0x3c1a052e8069>,pattern=0x3b1cc10dc9d9 <JSArray[2]>,index=0,inGlobStar=0x3e54afe828c9 <true>,cb=0x3fb631002289 <JSFunction done (sfi = 0x38603bd6c521)>)
    2: /* anonymous */ [0xd6c9ab719a1] [/home/smag/.config/yarn...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x8fa090 node::Abort() [node]
 2: 0x8fa0dc  [node]
 3: 0xb0039e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb005d4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xef4ae2  [node]
 6: 0xef4be8 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node]
 7: 0xf00cc2 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xf015f4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xf04261 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0xed3eab v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node]
11: 0x101d733 v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [node]
12: 0xafdd44 v8::internal::String::Flatten(v8::internal::Handle<v8::internal::String>, v8::internal::PretenureFlag) [node]
13: 0x101e89e v8::internal::StringTable::LookupString(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>) [node]
14: 0x119495b  [node]
15: 0x1196b69 v8::internal::Runtime_KeyedGetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [node]
16: 0x51e71dbe1d 
[1]    3279482 abort (core dumped)  serverless invoke local -f fun -d

NOTE: serverless deploy works fine

🌍 Your environment

Fedora Linux 31.

serverless version: Framework Core: 1.67.3 Plugin: 3.6.6 SDK: 2.3.0 Components: 2.29.0

rust-plugin version: 0.3.7

Using custom docker tag: 0.2.6-rust-1.42.0

softprops commented 4 years ago

I'm not sure if it helps but could you try the latest. There's also experimental support for a dockerless build option which might help https://github.com/softprops/serverless-rust#-experimental-local-builds

softprops commented 4 years ago

closing for now. free free to reopen if you are still able to reproduce the problem with the latest version