Skip to content

Cannot use RUST for ARM Graviton2 Lambda #354

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

Closed
Aleksandr-Filichkin opened this issue Oct 19, 2021 · 8 comments
Closed

Cannot use RUST for ARM Graviton2 Lambda #354

Aleksandr-Filichkin opened this issue Oct 19, 2021 · 8 comments

Comments

@Aleksandr-Filichkin
Copy link

Hi Everyone,

I'm trying to deploy RUST lambda for ARM lambda. I was able to compile the code for target 'aarch64-unknown-linux-gnu', but during invocation, I see such an error:
/var/task/bootstrap: line 3: 9 Segmentation fault (core dumped) ./app END RequestId: 048e5e8c-538a-4447-b917-b46414c3d377 REPORT RequestId: 048e5e8c-538a-4447-b917-b46414c3d377 Duration: 212.24 ms Billed Duration: 257 ms Memory Size: 256 MB Max Memory Used: 37 MB Init Duration: 44.59 ms XRAY TraceId: 1-616e7dfc-07e7e2237a96edf63c5b43e7 SegmentId: 2d628b5e454f8dee Sampled: true RequestId: 048e5e8c-538a-4447-b917-b46414c3d377 Error: Runtime exited with error: exit status 139Runtime.ExitError

All code you can find here (https://github.com/Aleksandr-Filichkin/aws-lambda-runtimes-performance/blob/arm-lambda/rust-aws-lambda/Dockerfile.arm)

The code works for the non-arm Lambda

@brainstorm
Copy link

brainstorm commented Oct 19, 2021

Hello @Aleksandr-Filichkin, my example code runs fine on ARM64 sans MUSL and it does not segfault, take a peek, happy to guide you through if there's something unclear?:

https://github.com/umccr/s3-rust-noodles-bam

I just use a very thin mod of the provided.al2 official image: https://github.com/umccr/s3-rust-noodles-bam/blob/master/Dockerfile-provided.al2

I was tempted to send you a PR when I saw your benchmarking since I'm interested in seeing the performance of ARM64 Rust lambdas with native vs MUSL static wrapping, but I'm glad to see you are actively tackling it already, keen to see the results :)

/cc @nmoutschen

@simonvandel
Copy link
Contributor

@Aleksandr-Filichkin

The docker image you are using to build the rust code uses glibc 2.28 as seen here https://github.com/docker-library/repo-info/blob/a1ebff8be128ff3af7692c79f98ffb7ece0cec63/repos/rust/local/1.54.md#dpkg-source-package-glibc228-10

But Afaikt Amazon Linux 2 only has 2.26 https://aws.amazon.com/amazon-linux-2/release-notes/

You can try building the rust code in a docker image based directly on Amazon Linux 2, so that you are certain that the Glibc version is compatible. You can get the latest rust compiler using rustup.

@simonvandel
Copy link
Contributor

I just tried RUSTFLAGS='-C target-cpu=neoverse-n1' cross build --release --target aarch64-unknown-linux-gnu which successfully runs on Lambda. This is using the https://github.com/rust-embedded/cross tool build, which internally uses Ubuntu 16.04 (https://github.com/rust-embedded/cross/blob/master/docker/Dockerfile.aarch64-unknown-linux-gnu#L1). This is libc 2.19 - I don't know how many ARM specifc optimizations went into that version - later libc's might be faster.

@brainstorm
Copy link

Interesting @simonvandel, thanks for sharing! ... where can I find a list for that target-cpu flag? Crossing fingers so that it supports Apple Silicon (see aws-samples/serverless-rust-demo#2 (comment)).

@simonvandel
Copy link
Contributor

where can I find a list for that target-cpu flag?

See https://doc.rust-lang.org/rustc/codegen-options/index.html#target-cpu

@brainstorm
Copy link

Thanks, pretty much any sensible ARM-like cpu on rustc --print target-cpus fails in the same way, I'll continue investigating in briansmith/ring#1332 (comment) and followups.

@coltonweaver
Copy link
Contributor

Hey! Have you given the latest README steps a shot? I was able to compile and run examples on ARM using Docker (on Apple silicon).

@nmoutschen
Copy link
Contributor

Hey @Aleksandr-Filichkin !

I see that you've made changes in your repository, so I will close this issue assuming that you made it work. Feel free to reopen with a status update if it's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants