Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-k-cameron committed Mar 5, 2023
1 parent bc98470 commit 670b873
Show file tree
Hide file tree
Showing 20 changed files with 544 additions and 36 deletions.
326 changes: 326 additions & 0 deletions tools/compile_time_benchmark/Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tools/compile_time_benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ edition = "2021"
[dependencies]
aws-config = "0.54.1"
aws-sdk-batch = "0.24.0"
aws-sdk-ec2 = "0.24.0"
aws-sdk-s3 = "0.24.0"
env_logger = "0.10.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#
compute_environment_name = "smithy_rs_benchmark"
type = "Managed"
state = "Enabled"

#service_role = null

[compute_resource]
type = "Ec2"
allocation_strategy = "BEST_FIT"
minv_cpus = 0
maxv_cpus = 256
instance_types = ["c7g.2xlarge"]
instance_role = "SmithyRs_CompileTimeBenchmarking_Ec2Role"

[compute_resource.launch_template]
launch_template_name = "smithy_rs_benchmarking"
version = "1"
1 change: 1 addition & 0 deletions tools/compile_time_benchmark/config/common/is_smithy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"smithy-rs" = "tools_compile_time_benchmark"
1 change: 0 additions & 1 deletion tools/compile_time_benchmark/config/constants.toml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
launch_template_name = "smithy_rs_benchmark_launch_template"
version_Description = "Template for c7.2xlarge instance. Change the instance type if AWS stops offering c7."

[[template_tags]]
key = "smithy-rs"
value = ""

[launch_template_data]
image_id = "ami-05bfbece1ed5beb54"
ebs_optimized = true
user_data = ""
instance_type = "C7g2Xlarge"

[launch_template_data.iam_instance_profile]
name = "smithy_rs_compilation_benchmark_role"

[launch_template_data.block_device_mappings]

[launch_template_data.network_interfaces]

[launch_template_data.network_interfaces]


[[tag_specifications]]
resource_type = "Instance"
key = "smithy-rs"
value = "
# ebs
[volumes]
device_name = "/dev/xvda"
volume_type = "gp2"
size = 100
3 changes: 3 additions & 0 deletions tools/compile_time_benchmark/config/iam/create_iam_role.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
role_name = "smithy_rs_compilation_benchmark_role"
description = "Compile time benchmark role for smithy-rs."
assume_role_policy_document = "AwsBatchFullAccess"
2 changes: 2 additions & 0 deletions tools/compile_time_benchmark/config/iam/create_user.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user_name = "SmithyRsBenchmarkUser"
permission_boundary = "AWSBatchFullAccess"
10 changes: 0 additions & 10 deletions tools/compile_time_benchmark/config/launch_template.toml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "smithy_rs_compilation_benchmark_resource_group"
description = """
Resources for benchmarking smithy-rs's compile time.
Resources here is created by `compile_time_benchmark` tool which you can find it on smithy-rs repository.
"""
Empty file.
124 changes: 124 additions & 0 deletions tools/compile_time_benchmark/config/role_policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeAccountAttributes",
"ec2:DescribeInstances",
"ec2:DescribeInstanceStatus",
"ec2:DescribeInstanceAttribute",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeKeyPairs",
"ec2:DescribeImages",
"ec2:DescribeImageAttribute",
"ec2:DescribeSpotInstanceRequests",
"ec2:DescribeSpotFleetInstances",
"ec2:DescribeSpotFleetRequests",
"ec2:DescribeSpotPriceHistory",
"ec2:DescribeVpcClassicLink",
"ec2:DescribeLaunchTemplateVersions",
"ec2:CreateLaunchTemplate",
"ec2:DeleteLaunchTemplate",
"ec2:RequestSpotFleet",
"ec2:CancelSpotFleetRequests",
"ec2:ModifySpotFleetRequest",
"ec2:TerminateInstances",
"ec2:RunInstances",
"autoscaling:DescribeAccountLimits",
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:CreateLaunchConfiguration",
"autoscaling:CreateAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
"autoscaling:SetDesiredCapacity",
"autoscaling:DeleteLaunchConfiguration",
"autoscaling:DeleteAutoScalingGroup",
"autoscaling:CreateOrUpdateTags",
"autoscaling:SuspendProcesses",
"autoscaling:PutNotificationConfiguration",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"ecs:DescribeClusters",
"ecs:DescribeContainerInstances",
"ecs:DescribeTaskDefinition",
"ecs:DescribeTasks",
"ecs:ListAccountSettings",
"ecs:ListClusters",
"ecs:ListContainerInstances",
"ecs:ListTaskDefinitionFamilies",
"ecs:ListTaskDefinitions",
"ecs:ListTasks",
"ecs:CreateCluster",
"ecs:DeleteCluster",
"ecs:RegisterTaskDefinition",
"ecs:DeregisterTaskDefinition",
"ecs:RunTask",
"ecs:StartTask",
"ecs:StopTask",
"ecs:UpdateContainerAgent",
"ecs:DeregisterContainerInstance",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogGroups",
"iam:GetInstanceProfile",
"iam:GetRole"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ecs:TagResource",
"Resource": [
"arn:aws:ecs:*:*:task/*_Batch_*"
]
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": [
"*"
],
"Condition": {
"StringEquals": {
"iam:PassedToService": [
"ec2.amazonaws.com",
"ec2.amazonaws.com.cn",
"ecs-tasks.amazonaws.com"
]
}
}
},
{
"Effect": "Allow",
"Action": "iam:CreateServiceLinkedRole",
"Resource": "*",
"Condition": {
"StringEquals": {
"iam:AWSServiceName": [
"spot.amazonaws.com",
"spotfleet.amazonaws.com",
"autoscaling.amazonaws.com",
"ecs.amazonaws.com"
]
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": [
"*"
],
"Condition": {
"StringEquals": {
"ec2:CreateAction": "RunInstances"
}
}
}
]
}
Empty file.
13 changes: 13 additions & 0 deletions tools/compile_time_benchmark/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# What's this?

This is a cli app that let's you to benchmark the compile time.
It is part of RFC30.


# Directories

# Constance
SmithyRs
SmithyRsBenchmark

IAM PROFILE NAME: SmithyRsIAMProfileForEC2
18 changes: 12 additions & 6 deletions tools/compile_time_benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ use std::{
path::{Path, PathBuf},
};

use aws_sdk_batch::model::JobDependency;
use serde::Serialize;
use tokio::{spawn, task::JoinError};

#[tokio::main]
fn main() {
println!("Hello, world!");
}

async fn async_main() {
let conf = aws_config::load_from_env().await;

}

struct SaveData {
Expand Down Expand Up @@ -56,10 +55,12 @@ impl SaveData {
}
}

async fn create_batch_resources(
async fn create_passive_resources(
client: aws_sdk_batch::Client,
ec2: aws_sdk_ec2::Client,
save_data: &mut SaveData,
) -> Result<(), JoinError> {
let x = ec2.create_launch_template().send().await;
let ce = tokio::spawn(client.create_compute_environment().send());
let queue = tokio::spawn(client.create_job_queue().send());
let definition = tokio::spawn(client.register_job_definition().send());
Expand All @@ -74,5 +75,10 @@ async fn drop_batch_resources(client: aws_sdk_batch::Client) -> Result<(), JoinE
}

async fn submit_job(client: aws_sdk_batch::Client) {
tokio::spawn(client.submit_job().send());
if let Ok(job) = client.submit_job().send().await {
client.submit_job().depends_on({
JobDependency::builder().job_id(job.job_id().unwrap()).build()
}).send().await;
}
let res = client.submit_job().send().await;
}

0 comments on commit 670b873

Please sign in to comment.