Skip to content

Commit

Permalink
Merge pull request #74 from Green-Software-Foundation/ccf-imp
Browse files Browse the repository at this point in the history
  • Loading branch information
gnanakeethan authored Aug 31, 2023
2 parents 51536f1 + c6f7202 commit f5a5f28
Show file tree
Hide file tree
Showing 22 changed files with 1,083 additions and 33 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ jobs:
node-version: 18
cache: 'yarn'


- name: Install dependencies
run: yarn install

- name: Run lint
run: yarn lint

- name: Build
run: yarn build

- name: Run tests
run: yarn test

- name: Run lint
run: yarn lint
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third-party/ccf-coefficients"]
path = third-party/ccf-coefficients
url = https://github.com/cloud-carbon-footprint/ccf-coefficients
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


#Converts the CSV files from CCF Coefficients Database to JSON.
ccf-data:
cat third-party/ccf-coefficients/data/aws-instances.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/aws-instances.json
cat third-party/ccf-coefficients/output/coefficients-aws-use.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/aws-use.json
cat third-party/ccf-coefficients/output/coefficients-aws-embodied.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/aws-embodied.json
cat third-party/ccf-coefficients/data/gcp-instances.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/gcp-instances.json
cat third-party/ccf-coefficients/output/coefficients-gcp-use.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/gcp-use.json
cat third-party/ccf-coefficients/output/coefficients-gcp-embodied.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/gcp-embodied.json
cat third-party/ccf-coefficients/data/azure-instances.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/azure-instances.json
cat third-party/ccf-coefficients/output/coefficients-azure-use.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/azure-use.json
cat third-party/ccf-coefficients/output/coefficients-azure-embodied.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > lib/ccf/azure-embodied.json
3 changes: 3 additions & 0 deletions docs/implementations/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Implementations

[CCF](./ccf.md) - Cloud Carbon Footprint Impact Plugin Documentation
83 changes: 83 additions & 0 deletions docs/implementations/ccf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Cloud Carbon Footprint

Cloud Carbon Footprint is an open source tool that provides visibility and tooling to measure, monitor and reduce your cloud carbon emissions. We use best practice methodologies to convert cloud utilization into estimated energy usage and carbon emissions, producing metrics and carbon savings estimates that can be shared with employees, investors, and other stakeholders.

## Implementation

IEF implements this plugin to the IEF Specification based on the computational methodology used by the Cloud Carbon Footprint.

Cloud Carbon Footprint includes calculations for three cloud providers namely AWS, Azure and GCP.

By default, Linear interpolation is used to estimate the energy. Interpolation is performed using the CPU Design Cycle, for example in Intel Chips, **CoffeeLake** and for example in AMD Chips, **EPYC 2nd Gen**.

Additionally, **TEADS model curve for AWS** available in the CCF dataset can be used for spline curve interpolation for instances in AWS infrastructure.

Resulting values are generally approximation and should be revalidated across different models as there can be significant difference between values.

New instances across all cloud providers might not be recognized by CCF. Earliest possible instances recognized are released before 2021 December.

## Usage

Configure method has to be called on the instantiated object before any other calls are done.

Calculate method expects an array of observations. Each observation should feature `duration`,`cpu`,`datetime` in the formats specified below.


### AWS

```typescript
import {CloudCarbonFootprint} from 'ief';

const ccf = new CloudCarbonFootprint();
ccf.configure({
provider: 'aws',
instance_type: 'c6i.large'
})
const results = ccf.calculate([
{
duration: 3600, // duration institute
cpu: 0.1, // CPU usage as a value between 0 and 1 in floating point number
datetime: '2021-01-01T00:00:00Z', // ISO8601 / RFC3339 timestamp
}
])
```

### Azure

```typescript
import {CloudCarbonFootprint} from 'ief';

const ccf = new CloudCarbonFootprint();
ccf.configure({
provider: 'azure',
instance_type: 'D4 v4'
})
const results = ccf.calculate([
{
duration: 3600, // duration institute
cpu: 0.1, // CPU usage as a value between 0 and 1 in floating point number
datetime: '2021-01-01T00:00:00Z', // ISO8601 / RFC3339 timestamp
}
])
```

### GCP

```typescript
import {CloudCarbonFootprint} from 'ief';

const ccf = new CloudCarbonFootprint();
ccf.configure({
provider: 'aws',
instance_type: 'n2-standard-2'
})
const results = ccf.calculate([
{
duration: 3600, // duration institute
cpu: 0.1, // CPU usage as a value between 0 and 1 in floating point number
datetime: '2021-01-01T00:00:00Z', // ISO8601 / RFC3339 timestamp
}
])
```


5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
"typescript",
"ts-sync-request",
"@cloud-carbon-footprint/core",
"@cloud-carbon-footprint/aws",
"typescript-cubic-spline",
"js-yaml",
"@types/node"
],
"dependencies": {
"@cloud-carbon-footprint/core": "*",
"@cloud-carbon-footprint/aws": "^0.14.5",
"typescript-cubic-spline": "*",
"@types/node": "^20.4.5",
"axios": "^1.4.0",
"js-yaml": "^4.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/lib/ccf/aws-embodied.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lib/ccf/aws-instances.json

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions src/lib/ccf/aws-use.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[
{
"": "0",
"Architecture": "Graviton",
"Min Watts": "0.4742621527777778",
"Max Watts": "1.6929615162037037",
"GB/Chip": "129.77777777777777"
},
{
"": "1",
"Architecture": "Ivy Bridge",
"Min Watts": "3.0369270833333335",
"Max Watts": "8.248611111111112",
"GB/Chip": "14.933333333333334"
},
{
"": "2",
"Architecture": "Sandy Bridge",
"Min Watts": "2.1694411458333334",
"Max Watts": "8.575357663690477",
"GB/Chip": "16.480916030534353"
},
{
"": "3",
"Architecture": "Haswell",
"Min Watts": "1.9005681818181814",
"Max Watts": "6.012910353535353",
"GB/Chip": "27.310344827586206"
},
{
"": "4",
"Architecture": "Sky Lake",
"Min Watts": "0.6446044454253452",
"Max Watts": "4.193436438541878",
"GB/Chip": "80.43037974683544"
},
{
"": "5",
"Architecture": "Cascade Lake",
"Min Watts": "0.6389493581523519",
"Max Watts": "3.9673047343937564",
"GB/Chip": "98.11764705882354"
},
{
"": "6",
"Architecture": "EPYC 2nd Gen",
"Min Watts": "0.4742621527777778",
"Max Watts": "1.6929615162037037",
"GB/Chip": "129.77777777777777"
},
{
"": "7",
"Architecture": "Graviton2",
"Min Watts": "0.4742621527777778",
"Max Watts": "1.6929615162037037",
"GB/Chip": "129.77777777777777"
},
{
"": "8",
"Architecture": "Broadwell",
"Min Watts": "0.7128342245989304",
"Max Watts": "3.6853275401069516",
"GB/Chip": "69.6470588235294"
},
{
"": "9",
"Architecture": "EPYC 1st Gen",
"Min Watts": "0.82265625",
"Max Watts": "2.553125",
"GB/Chip": "89.6"
},
{
"": "10",
"Architecture": "Coffee Lake",
"Min Watts": "1.138425925925926",
"Max Watts": "5.421759259259258",
"GB/Chip": "19.555555555555557"
}
]
1 change: 1 addition & 0 deletions src/lib/ccf/azure-embodied.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lib/ccf/azure-instances.json

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions src/lib/ccf/azure-use.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"": "0",
"Architecture": "EPYC 3rd Gen",
"Min Watts": "0.44538981119791665",
"Max Watts": "2.0193277994791665",
"GB/Chip": "128.0"
},
{
"": "1",
"Architecture": "Haswell",
"Min Watts": "1.9005681818181814",
"Max Watts": "6.012910353535353",
"GB/Chip": "27.310344827586206"
},
{
"": "2",
"Architecture": "Cascade Lake",
"Min Watts": "0.6389493581523519",
"Max Watts": "3.9673047343937564",
"GB/Chip": "98.11764705882354"
},
{
"": "3",
"Architecture": "Skylake",
"Min Watts": "0.6446044454253452",
"Max Watts": "4.193436438541878",
"GB/Chip": "80.43037974683544"
},
{
"": "4",
"Architecture": "Broadwell",
"Min Watts": "0.7128342245989304",
"Max Watts": "3.6853275401069516",
"GB/Chip": "69.6470588235294"
},
{
"": "5",
"Architecture": "EPYC 2nd Gen",
"Min Watts": "0.4742621527777778",
"Max Watts": "1.6929615162037037",
"GB/Chip": "129.77777777777777"
},
{
"": "6",
"Architecture": "Coffee Lake",
"Min Watts": "1.138425925925926",
"Max Watts": "5.421759259259258",
"GB/Chip": "19.555555555555557"
},
{
"": "7",
"Architecture": "EPYC 1st Gen",
"Min Watts": "0.82265625",
"Max Watts": "2.553125",
"GB/Chip": "89.6"
}
]
1 change: 1 addition & 0 deletions src/lib/ccf/gcp-embodied.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lib/ccf/gcp-instances.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lib/ccf/gcp-use.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"": "0", "Architecture": "Skylake", "Min Watts": "0.6446044454253452", "Max Watts": "3.8984738056304855", "GB/Chip": "80.43037974683544"}, {"": "1", "Architecture": "Broadwell", "Min Watts": "0.7128342245989304", "Max Watts": "3.3857473048128344", "GB/Chip": "69.6470588235294"}, {"": "2", "Architecture": "Haswell", "Min Watts": "1.9005681818181814", "Max Watts": "5.9688982156043195", "GB/Chip": "27.310344827586206"}, {"": "3", "Architecture": "EPYC 2nd Gen", "Min Watts": "0.4742621527777778", "Max Watts": "1.5751872939814815", "GB/Chip": "129.77777777777777"}, {"": "4", "Architecture": "Cascade Lake", "Min Watts": "0.6389493581523519", "Max Watts": "3.6424520285114035", "GB/Chip": "98.11764705882354"}, {"": "5", "Architecture": "EPYC 3rd Gen", "Min Watts": "0.44538981119791665", "Max Watts": "1.8719357994791666", "GB/Chip": "128.0"}, {"": "6", "Architecture": "Ivy Bridge", "Min Watts": "3.0369270833333335", "Max Watts": "8.199689511111112", "GB/Chip": "14.933333333333334"}, {"": "7", "Architecture": "Sandy Bridge", "Min Watts": "2.1694411458333334", "Max Watts": "8.550185877430936", "GB/Chip": "16.480916030534353"}]
Loading

0 comments on commit f5a5f28

Please sign in to comment.