Skip to content

Commit

Permalink
[fix] try using mimalloc on musl (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
jplock authored Feb 3, 2025
1 parent 8b441a8 commit 497e8ed
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: 3.x
cache: pip
Expand Down
87 changes: 53 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/dependencies/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aws-lambda-powertools[tracer,parser]==3.4.1
aws-lambda-powertools[tracer,parser]==3.5.0
cryptography==43.0.3
hpke==0.3.2
pksuid==1.1.2
Expand Down
2 changes: 1 addition & 1 deletion api/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
black==24.10.0
aws-lambda-powertools[all,aws-sdk]==3.4.1
aws-lambda-powertools[all,aws-sdk]==3.5.0
boto3-stubs[dynamodb,kms]
2 changes: 1 addition & 1 deletion canary/dependencies/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aws-lambda-powertools==3.4.1
aws-lambda-powertools==3.5.0
2 changes: 1 addition & 1 deletion canary/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
black==24.10.0
aws-lambda-powertools[all,aws-sdk]==3.4.1
aws-lambda-powertools[all,aws-sdk]==3.5.0
boto3-stubs[dynamodb,kms]
28 changes: 22 additions & 6 deletions ci_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -913,12 +913,6 @@ Resources:
- Effect: Allow
Action: "s3:ListBucket" # required for Lambda code signing
Resource: !GetAtt rArtifactBucket.Arn
- Effect: Allow
Action: "secretsmanager:GetSecretValue"
Resource: !Ref rSigningSecret
- Effect: Allow
Action: "secretsmanager:PutSecretValue"
Resource: !Ref rMeasurementSecret
- Effect: Allow
Action: "signer:StartSigningJob"
Resource: !Ref rSigningProfile
Expand All @@ -937,6 +931,28 @@ Resources:
- Key: "dp:exclude:network"
Value: "true"

rSecretsManagerPolicy:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: SecretsManager
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "secretsmanager:GetSecretValue"
Resource: !Ref rSigningSecret
Condition:
ArnEquals:
"codebuild:projectArn": !GetAtt rVaultCodeBuildProject.Arn
- Effect: Allow
Action: "secretsmanager:PutSecretValue"
Resource: !Ref rMeasurementSecret
Condition:
ArnEquals:
"codebuild:projectArn": !GetAtt rVaultCodeBuildProject.Arn
Roles:
- !Ref rCodeBuildRole

rCloudWatchLogsPolicy:
Type: "AWS::IAM::Policy"
Properties:
Expand Down
7 changes: 5 additions & 2 deletions enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ cel-interpreter = { version = "=0.9.0", default-features = false, features = ["j
chrono = { version = "=0.4.39", default-features = false, features = ["now"] }
data-encoding = { version = "=2.7.0", default-features = false, features = ["alloc"] }
serde = { version = "=1.0.217", default-features = false, features = ["derive"] }
serde_json = { version = "=1.0.137", default-features = false }
rustls = { version = "=0.23.21", default-features = false, features = ["aws_lc_rs"] }
serde_json = { version = "=1.0.138", default-features = false }
rustls = { version = "=0.23.22", default-features = false, features = ["aws_lc_rs"] }
vsock = { version = "=0.5.1", default-features = false }
zeroize = { version = "=1.8.1", default-features = false, features = ["zeroize_derive"] }

[target.'cfg(target_env = "musl")'.dependencies]
mimalloc = { version = "=0.1.43", default-features = false, features = ["secure"] }
5 changes: 5 additions & 0 deletions enclave/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ use enclave_vault::{
use rustls::crypto::hpke::HpkePrivateKey;
use vsock::{VsockAddr, VsockListener, VsockStream, VMADDR_CID_ANY};

// Avoid musl's default allocator due to terrible performance
#[cfg(target_env = "musl")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[inline]
fn parse_payload(payload_buffer: &[u8]) -> Result<EnclaveRequest> {
let payload: EnclaveRequest = serde_json::from_slice(payload_buffer)
Expand Down
2 changes: 1 addition & 1 deletion parent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ byteorder = { version = "=1.5.0", default-features = false }
clap = { version = "=4.5.27", default-features = false, features = ["std", "derive", "env"] }
fastrand = { version = "=2.3.0", default-features = false }
serde = { version = "=1.0.217", default-features = false, features = ["derive"] }
serde_json = { version = "=1.0.137", default-features = false }
serde_json = { version = "=1.0.138", default-features = false }
thiserror = { version = "=2.0.11", default-features = false }
tokio = { version = "=1.43.0", default-features = false, features = ["rt-multi-thread", "process", "tracing"] }
tracing = { version = "=0.1.41", default-features = false, features = ["log"] }
Expand Down
3 changes: 3 additions & 0 deletions vault_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ Resources:
- Effect: Allow
Action: "s3:GetObject"
Resource: !Sub "arn:${AWS::Partition}:s3:::${pArtifactBucketName}/${pArtifactObjectKey}"
Condition:
StringEquals:
"aws:ResourceAccount": !Ref "AWS::AccountId"
- Effect: Allow
Action:
- "cloudformation:DescribeStackResource"
Expand Down

0 comments on commit 497e8ed

Please sign in to comment.