6

畫 Python 下記憶體使用情況的 Flamegraph:Memray

 2 years ago
source link: https://blog.gslin.org/archives/2022/04/25/10676/%e7%95%ab-python-%e4%b8%8b%e8%a8%98%e6%86%b6%e9%ab%94%e4%bd%bf%e7%94%a8%e6%83%85%e6%b3%81%e7%9a%84-flamegraph%ef%bc%9amemray/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

畫 Python 下記憶體使用情況的 Flamegraph:Memray

前幾天的 Hacker News Daily 上看到的東西,是由 Bloomberg 開發出來的工具 Memray,這個工具是一個 Python 套件:

Memray is a memory profiler for Python. It can track memory allocations in Python code, in native extension modules, and in the Python interpreter itself.

套件有多種輸出,其中一種是可以產生出記憶體使用情況的 flamegraph,轉成圖檔後像是這樣:

官方支援 Python 3.7+:

Memray requires Python 3.7+ and can be easily installed using most common Python packaging tools.

用法看起來也很簡單,之後如果有需要看 memory footprint 的情況好像可以拿來用看看...

Related

用 pipsi 管 Python 的 command line 工具...

在「My Python Development Environment, 2018 Edition « Jacob Kaplan-Moss」這邊看到 Python 開發有哪些工具可以用 (介紹了三個),其中管理不同 Python 版本的 pyenv 用一陣子了,另外兩個則是之前沒用過... pipsi 是將套件用 virtualenv 包起來,讓使用者在用的時候不會受到其他環境的干擾。我是拿來跟系統的 python3 (目前在 Ubuntu 16.04 上是指到 3.5.1) 使用,所以安裝 pipsi 時先切到 system 再透過 python3 安裝 (讓他偵測到系統的 python3): $ pyenv shell system $ which python3 $ curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python3 接著把 PATH 參數設好後…

February 25, 2018

In "Computer"

合併 RRD 資料的工具

昨天把跑在 Raspberry Pi 上的 SmokePing 資料改用統一版本 (我在 GitHub 上公開的 smokeping-config.d 這個),但有些節點的 naming 改變了,所以會需要將資料整在一起。 在透過 Google 搜尋後,用的工具是「A very simple script to merge multiple RRD files, since none of those available seem to work.」這個,是一隻 Python 的程式。另外可以從程式碼裡面看到他使用了 rrdtool 這個 CLI 工具 (SmokePing 用了 RRD 格式儲存資料),所以使用這隻程式前需要先安裝 rrdtool 這個套件: $ sudo apt install rrdtool 接下來就是照說明來轉換。由於…

May 22, 2018

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on April 25, 2022April 25, 2022Categories Computer, Library, Murmuring, Programming, SoftwareTags bloomberg, flamegraph, memory, memray, profiling, python, usage

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK