Skip to content

Commit 9dd63eb

Browse files
Merge pull request #827 from pyathena-dev/feat/644-benchmark-arm64
Allow Graviton benchmark hosts with an architecture parameter
2 parents 6900982 + c6c6f97 commit 9dd63eb

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

‎benchmarks/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ There is no inbound security-group rule or SSH key; use Session Manager.
9292
Internet access permits package installation and calls to AWS APIs without a NAT gateway.
9393

9494
The defaults are Amazon Linux 2023 x86_64, `r7i.2xlarge` (8 vCPUs, 64 GiB), and an encrypted 100 GiB gp3 root volume.
95+
Set `Architecture=arm64` with an `r7g` or `r8g` instance type to run on AWS Graviton; the template rejects an instance type that does not match the architecture.
96+
Measurements depend on the CPU architecture; `environment.json` records it, and runs on different architectures are not directly comparable.
9597
Instance size and disk size are parameters, so a later run can deliberately test another memory budget.
9698
The AMI parameter resolves the current AL2023 image at deployment; record the resulting AMI when comparing environments.
9799
Source bucket access is read-only and restricted to the configured prefix.

‎benchmarks/cloudformation/benchmark.yaml‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ Parameters:
1919
Type: String
2020
AllowedPattern: '[0-9a-f]{40}'
2121
Description: Full commit SHA containing the benchmark implementation.
22+
Architecture:
23+
Type: String
24+
Default: x86_64
25+
AllowedValues: [x86_64, arm64]
26+
Description: CPU architecture of the benchmark hosts; it must match the instance type.
2227
InstanceType:
2328
Type: String
2429
Default: r7i.2xlarge
25-
AllowedValues: [r7i.large, r7i.xlarge, r7i.2xlarge, r7i.4xlarge, r7i.8xlarge]
30+
AllowedValues: [r7i.large, r7i.xlarge, r7i.2xlarge, r7i.4xlarge, r7i.8xlarge, r7g.large, r7g.xlarge, r7g.2xlarge, r7g.4xlarge, r7g.8xlarge, r8g.large, r8g.xlarge, r8g.2xlarge, r8g.4xlarge, r8g.8xlarge]
2631
VolumeSize:
2732
Type: Number
2833
Default: 100
@@ -31,6 +36,11 @@ Parameters:
3136
ImageId:
3237
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
3338
Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64
39+
Description: Image for x86_64 hosts.
40+
Arm64ImageId:
41+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
42+
Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64
43+
Description: Image for arm64 hosts.
3444
UvVersion:
3545
Type: String
3646
Default: '0.12.5'
@@ -60,6 +70,21 @@ Parameters:
6070
Default: pypi_file_downloads
6171
AllowedPattern: '[a-z][a-z0-9_]*'
6272

73+
Rules:
74+
X86InstanceType:
75+
RuleCondition: !Equals [!Ref Architecture, x86_64]
76+
Assertions:
77+
- Assert: !Contains [[r7i.large, r7i.xlarge, r7i.2xlarge, r7i.4xlarge, r7i.8xlarge], !Ref InstanceType]
78+
AssertDescription: Use an r7i instance type with the x86_64 architecture.
79+
Arm64InstanceType:
80+
RuleCondition: !Equals [!Ref Architecture, arm64]
81+
Assertions:
82+
- Assert: !Contains [[r7g.large, r7g.xlarge, r7g.2xlarge, r7g.4xlarge, r7g.8xlarge, r8g.large, r8g.xlarge, r8g.2xlarge, r8g.4xlarge, r8g.8xlarge], !Ref InstanceType]
83+
AssertDescription: Use an r7g or r8g instance type with the arm64 architecture.
84+
85+
Conditions:
86+
IsArm64: !Equals [!Ref Architecture, arm64]
87+
6388
Resources:
6489
Vpc:
6590
Type: AWS::EC2::VPC
@@ -205,7 +230,7 @@ Resources:
205230
MetadataOptions:
206231
HttpTokens: required
207232
HttpEndpoint: enabled
208-
ImageId: !Ref ImageId
233+
ImageId: !If [IsArm64, !Ref Arm64ImageId, !Ref ImageId]
209234
InstanceType: !Ref InstanceType
210235
IamInstanceProfile:
211236
Arn: !GetAtt InstanceProfile.Arn

‎benchmarks/tests/test_cloudformation.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,24 @@ def test_fleet_size_controls_identical_hosts_and_signals():
4747
template["Resources"]["LaunchTemplate"]["Properties"]["LaunchTemplateData"]["UserData"]
4848
)
4949
assert "AutoScalingGroup" in template["Outputs"]
50+
51+
52+
def test_architecture_selects_the_image_and_rules_match_instance_families():
53+
template, errors = decode(
54+
str(Path(__file__).resolve().parents[1] / "cloudformation/benchmark.yaml")
55+
)
56+
assert not errors
57+
launch = template["Resources"]["LaunchTemplate"]["Properties"]["LaunchTemplateData"]
58+
assert launch["ImageId"] == {"Fn::If": ["IsArm64", {"Ref": "Arm64ImageId"}, {"Ref": "ImageId"}]}
59+
assert "arm64" in template["Parameters"]["Arm64ImageId"]["Default"]
60+
assert "x86_64" in template["Parameters"]["ImageId"]["Default"]
61+
allowed = set(template["Parameters"]["InstanceType"]["AllowedValues"])
62+
families = {}
63+
for name, architecture in (("X86InstanceType", "x86_64"), ("Arm64InstanceType", "arm64")):
64+
rule = template["Rules"][name]
65+
assert rule["RuleCondition"] == {"Fn::Equals": [{"Ref": "Architecture"}, architecture]}
66+
families[architecture] = set(rule["Assertions"][0]["Assert"]["Fn::Contains"][0])
67+
assert families["x86_64"] | families["arm64"] == allowed
68+
assert not families["x86_64"] & families["arm64"]
69+
assert all(t.startswith("r7i.") for t in families["x86_64"])
70+
assert all(t.startswith(("r7g.", "r8g.")) for t in families["arm64"])

0 commit comments

Comments
 (0)