使用 Graviton Porting Advisor 來遷移到 AWS Graviton

更新 發佈閱讀 23 分鐘

可以分析源代碼並檢查在遷移到 AWS Graviton 時需要更改的過時運行library

優化 aws 成本的方法之一是遷移到並採用具有高性價比的AWS Graviton

推薦使用AWS Graviton,從可持續性的角度來看,它有很好的表現

但有需要注意的地方:

  • 不適用於所有操作系統和實例類型
  • 由於處理器設計和正在運行的應用程序規範,可能無法實現預期性能

特別是有這兩點高度依賴於正在執行的應用程序的要求而不是基礎設施,因此建議在遷移之前進行驗證

因此,在 GitHub 上發布了遷移指南

https://github.com/aws/aws-graviton-getting-started

https://github.com/aws/aws-graviton-getting-started/blob/main/transition-guide.md

在上面的文章中,介紹了Graviton 的 Porting Advisor 作為一種工具來幫助分析和更改工作負載中的軟體


嘗試使用

https://github.com/aws/porting-advisor-for-graviton

目前要分析的語言和檢查對像如下

  • Python 3+
    • Python version
    • PIP version
    • Dependency versions in requirements.txt file
  • Java 8+
    • Java version
    • Dependency versions in pom.xml file
    • JAR scanning for native method calls (requires JAVA to be installed)
  • Go 1.11+
    • Go version
    • Dependency versions on go.mod file
  • C, C++, Fortran
    • Inline assembly with no corresponding aarch64 inline assembly.
    • Assembly source files with no corresponding aarch64 assembly source files.
    • Missing aarch64 architecture detection in autoconf config.guess scripts.
    • Linking against libraries that are not available on the aarch64 architecture.
    • Use of architecture specific intrinsic.
    • Preprocessor errors that trigger when compiling on aarch64.
    • Use of old Visual C++ runtime (Windows specific).
    • The following types of issues are detected, but not reported by default:
      • Compiler specific code guarded by compiler specific pre-defined macros.
    • The following types of cross-compile specific issues are detected, but not reported by default.
      • Architecture detection that depends on the host rather than the target.
      • Use of build artifacts in the build process.

先決條件

  • Python 3.10 or above (with PIP3 and venv module installed).
  • (Optionally) Open JDK 17 (or above) and Maven 3.5 (or above) if you want to scan JAR files for native methods.


確認版本

#  python3 --version
Python 3.10.6


下載檔案

root@ip-10-0-5-161:~# git clone https://github.com/aws/porting-advisor-for-graviton.git
Cloning into 'porting-advisor-for-graviton'...
remote: Enumerating objects: 333, done.
remote: Counting objects: 100% (333/333), done.
remote: Compressing objects: 100% (206/206), done.
remote: Total 333 (delta 102), reused 302 (delta 87), pack-reused 0
Receiving objects: 100% (333/333), 144.62 KiB | 3.71 MiB/s, done.
Resolving deltas: 100% (102/102), done.
root@ip-10-0-5-161:~#
root@ip-10-0-5-161:~# ls
porting-advisor-for-graviton


建立虛擬環境

root@ip-10-0-5-161:~# python3 -m venv .venv
root@ip-10-0-5-161:~#
root@ip-10-0-5-161:~# source .venv/bin/activate
(.venv) root@ip-10-0-5-161:~#


安裝library套件

(.venv) root@ip-10-0-5-161:~# cd porting-advisor-for-graviton
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# pip3 install -r requirements.txt
Collecting altgraph==0.17.2
Downloading altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
Collecting Jinja2==3.1.2
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 KB 4.5 MB/s eta 0:00:00
Collecting MarkupSafe==2.1.1
Downloading MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting packaging==21.3
Downloading packaging-21.3-py3-none-any.whl (40 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 KB 7.4 MB/s eta 0:00:00
Collecting progressbar33==2.4
Downloading progressbar33-2.4.tar.gz (10 kB)
Preparing metadata (setup.py) ... done
Collecting pyparsing==3.0.9
Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 KB 20.3 MB/s eta 0:00:00
Collecting XlsxWriter==3.0.3
Downloading XlsxWriter-3.0.3-py3-none-any.whl (149 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 150.0/150.0 KB 10.8 MB/s eta 0:00:00
Using legacy 'setup.py install' for progressbar33, since package 'wheel' is not installed.
Installing collected packages: progressbar33, altgraph, XlsxWriter, pyparsing, MarkupSafe, packaging, Jinja2
Running setup.py install for progressbar33 ... done
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.1 XlsxWriter-3.0.3 altgraph-0.17.2 packaging-21.3 progressbar33-2.4 pyparsing-3.0.9
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#


用sample示範

root@ip-10-0-5-161:~/porting-advisor-for-graviton# ls sample-projects/
dotnet-samples go-samples java-samples node-samples python-samples ruby-samples
root@ip-10-0-5-161:~/porting-advisor-for-graviton#


執行檢查

(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples
| Elapsed Time: 0:00:03

Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:06:27

4 files scanned.
detected python code. if you need pip, version 19.3 or above is recommended. we detected that you have version 22.0.2.
detected python code. min version 3.7.5 is required. we detected that you have version 3.10.6. see https://github.com/aws/aws-graviton-getting-started/blob/main/python.md for mo
re details.
sample-projects/python-samples/incompatible/requirements.txt:3: using dependency library openblas version 0.3.16. upgrade to at least version 0.3.17
sample-projects/python-samples/incompatible/requirements.txt:5: dependency library numpy is present. min version 1.19.0 is required.

Report generated successfully. Hint: you can use --output FILENAME.html to generate an HTML report.
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#


檢查發現了以下兩個需要升級

  • openblas
  • numpy
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# cat sample-projects/python-samples/incompatible/requirements.txt
# Porting Advisor for Graviton test file

OpenBLAS>=0.3.16
SciPy>=1.7.1
NumPy
FakeDependency>=1.2.3(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#


產生報告 html、json、csv、txt

(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.html
| Elapsed Time: 0:00:03

Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:10:38

Report saved at: report.html
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.json
| Elapsed Time: 0:00:03

Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:11:17

Report saved at: report.json
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.csv
| Elapsed Time: 0:00:03

Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:11:27

Report saved at: report.csv
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# python3 src/porting-advisor.py sample-projects/python-samples --output report.txt
| Elapsed Time: 0:00:02

Porting Advisor for Graviton v1.0.0
Report date: 2023-03-02 07:11:35

Report saved at: report.txt
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton# ls report.*
report.csv report.html report.json report.txt
(.venv) root@ip-10-0-5-161:~/porting-advisor-for-graviton#


report.json


{
"errors": [],
"issue_types": "-CompilerSpecific,-CrossCompile,-NoEquivalent",
"issues": [
"DependencyVersionIssue: sample-projects/python-samples/incompatible/requirements.txt:3: using dependency library openblas version 0.3.16. upgrade to at least version 0.
3.17"
],
"open_text_mode": "w",
"ported_inline_asm": 0,
"remarks": [
"LanguageVersionRemark: detected python code. min version 3.7.5 is required. we detected that you have version 3.10.6. see https://github.com/aws/aws-graviton-getting-st
arted/blob/main/python.md for more details.",
"ToolVersionRemark: detected python code. if you need pip, version 19.3 or above is recommended. we detected that you have version 22.0.2.",
"DependencyVersionRemark: sample-projects/python-samples/incompatible/requirements.txt:5: dependency library numpy is present. min version 1.19.0 is required."
],
"root_directory": "sample-projects/python-samples",
"self_process": false,
"send_filename": false,
"source_dirs": [
"sample-projects/python-samples/compatible",
"sample-projects/python-samples",
"sample-projects/python-samples/incompatible"
],
"source_files": [
"sample-projects/python-samples/main.py",
"sample-projects/python-samples/submain.py",
"sample-projects/python-samples/incompatible/requirements.txt",
"sample-projects/python-samples/compatible/requirements.txt"
],
"target_os": "linux"
}


report.txt

4 files scanned.
detected python code. if you need pip, version 19.3 or above is recommended. we detected that you have version 22.0.2.
detected python code. min version 3.7.5 is required. we detected that you have version 3.10.6. see https://github.com/aws/aws-graviton-getting-started/blob/main/python.md for more details.
sample-projects/python-samples/incompatible/requirements.txt:3: using dependency library openblas version 0.3.16. upgrade to at least version 0.3.17
sample-projects/python-samples/incompatible/requirements.txt:5: dependency library numpy is present. min version 1.19.0 is required.


report.html

raw-image



留言
avatar-img
留言分享你的想法!
avatar-img
西尼亞ming的沙龍
16會員
80內容數
西尼亞ming的沙龍的其他內容
2024/11/05
在ops-agent當中可以安裝 JVM 來收集 Java 參數,該工具主要收集 memory 以及 garbage collection 的參數,其中監控的選項有包含以下: jvm.classes.loaded jvm.gc.collections.count jvm.gc.collec
2024/11/05
在ops-agent當中可以安裝 JVM 來收集 Java 參數,該工具主要收集 memory 以及 garbage collection 的參數,其中監控的選項有包含以下: jvm.classes.loaded jvm.gc.collections.count jvm.gc.collec
2024/11/05
**Google Cloud 操作與 Audit Logs 說明** Google Cloud 作為純雲端服務提供商,所有操作均透過 HTTPS 網頁或 API 呼叫完成,並無「登入專案」的行為紀錄。不過,若使用 Google Workspace 管理使用者身份,則可以透過 Google
2024/11/05
**Google Cloud 操作與 Audit Logs 說明** Google Cloud 作為純雲端服務提供商,所有操作均透過 HTTPS 網頁或 API 呼叫完成,並無「登入專案」的行為紀錄。不過,若使用 Google Workspace 管理使用者身份,則可以透過 Google
2024/11/05
使用 Storage Transfer 服務是否能降低成本? Storage Transfer 的計價方式針對從 Cloud Storage 轉移至 Cloud Storage,除了一般費用外,Storage 移轉服務會使用 Cloud Storage rewrite 作業在 Cloud
2024/11/05
使用 Storage Transfer 服務是否能降低成本? Storage Transfer 的計價方式針對從 Cloud Storage 轉移至 Cloud Storage,除了一般費用外,Storage 移轉服務會使用 Cloud Storage rewrite 作業在 Cloud
看更多
你可能也想看
Thumbnail
還在煩惱平凡日常該如何增添一點小驚喜嗎?全家便利商店這次聯手超萌的馬來貘,推出黑白配色的馬來貘雪糕,不僅外觀吸睛,層次豐富的雙層口味更是讓人一口接一口!本文將帶你探索馬來貘雪糕的多種創意吃法,從簡單的豆漿燕麥碗、藍莓果昔,到大人系的奇亞籽布丁下午茶,讓可愛的馬來貘陪你度過每一餐,增添生活中的小確幸!
Thumbnail
還在煩惱平凡日常該如何增添一點小驚喜嗎?全家便利商店這次聯手超萌的馬來貘,推出黑白配色的馬來貘雪糕,不僅外觀吸睛,層次豐富的雙層口味更是讓人一口接一口!本文將帶你探索馬來貘雪糕的多種創意吃法,從簡單的豆漿燕麥碗、藍莓果昔,到大人系的奇亞籽布丁下午茶,讓可愛的馬來貘陪你度過每一餐,增添生活中的小確幸!
Thumbnail
在讀取檔案時,最怕路徑的問題,常常會有路徑錯誤造成的異常報錯。 為了避免諸如此類的問題發生,明白程式的當前目錄與檔案的路徑是很重要的。 可以利用os 模組是 Python 中的一個標準庫,提供了許多與操作系統的功能。 以下是一些常用的 os 模組基本操作及其範例: 1. os.getcwd
Thumbnail
在讀取檔案時,最怕路徑的問題,常常會有路徑錯誤造成的異常報錯。 為了避免諸如此類的問題發生,明白程式的當前目錄與檔案的路徑是很重要的。 可以利用os 模組是 Python 中的一個標準庫,提供了許多與操作系統的功能。 以下是一些常用的 os 模組基本操作及其範例: 1. os.getcwd
Thumbnail
在Python中,import是一個關鍵字,用於將其他模組或套件中的程式碼引入到當前的程式中以供使用。 這個關鍵字允許你在你的程式中使用其他地方定義的變數、函式和類等。 當你使用import時,Python會搜索指定模組或套件的位置,並將其中的程式碼載入到你的程式中,這樣你就可以在程式中使用它們
Thumbnail
在Python中,import是一個關鍵字,用於將其他模組或套件中的程式碼引入到當前的程式中以供使用。 這個關鍵字允許你在你的程式中使用其他地方定義的變數、函式和類等。 當你使用import時,Python會搜索指定模組或套件的位置,並將其中的程式碼載入到你的程式中,這樣你就可以在程式中使用它們
Thumbnail
當我們在撰寫一套系統的時候, 總是會提供一個介面讓使用者來觸發功能模組並回傳使用者所需的請求, 而傳統的安裝包模式總是太侷限, 需要個別主機獨立安裝, 相當繁瑣, 但隨著時代的演進與互聯網的崛起, 大部分的工作都可以藉由網頁端、裝置端來觸發, 而伺服端則是負責接收指令、運算與回傳結果, 雲端
Thumbnail
當我們在撰寫一套系統的時候, 總是會提供一個介面讓使用者來觸發功能模組並回傳使用者所需的請求, 而傳統的安裝包模式總是太侷限, 需要個別主機獨立安裝, 相當繁瑣, 但隨著時代的演進與互聯網的崛起, 大部分的工作都可以藉由網頁端、裝置端來觸發, 而伺服端則是負責接收指令、運算與回傳結果, 雲端
Thumbnail
歡迎來到 【🔒程式碼質量案例 】 系列, 這邊我們將分享實際開發過程中會遇到的程式碼難以維護的案例及解決方法, 期望透過這些技巧讓我們的產品更加的穩健也更容易於維護。 P.S 本篇會以Python程式語言進行示範, 其他語言的處理方式也雷同, 包括Javascript、Golang…等。
Thumbnail
歡迎來到 【🔒程式碼質量案例 】 系列, 這邊我們將分享實際開發過程中會遇到的程式碼難以維護的案例及解決方法, 期望透過這些技巧讓我們的產品更加的穩健也更容易於維護。 P.S 本篇會以Python程式語言進行示範, 其他語言的處理方式也雷同, 包括Javascript、Golang…等。
Thumbnail
從 JavaScript 到 Python
Thumbnail
從 JavaScript 到 Python
Thumbnail
可以分析源代碼並檢查在遷移到 AWS Graviton 時需要更改的過時運行library 優化 aws 成本的方法之一是遷移到並採用具有高性價比的AWS Graviton 推薦使用AWS Graviton,從可持續性的角度來看,它有很好的表現 但有需要注意的地方: 不適用於所有操作系統和實
Thumbnail
可以分析源代碼並檢查在遷移到 AWS Graviton 時需要更改的過時運行library 優化 aws 成本的方法之一是遷移到並採用具有高性價比的AWS Graviton 推薦使用AWS Graviton,從可持續性的角度來看,它有很好的表現 但有需要注意的地方: 不適用於所有操作系統和實
追蹤感興趣的內容從 Google News 追蹤更多 vocus 的最新精選內容追蹤 Google News