Consider using object pools for internal state keeping
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 20/100
- issue の種類
- リファクタリング
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- performance
調査の方向性
この issue にはソースファイル、エントリポイント、テストが記載されていないため、まず scheduler における set の割り当てをプロファイリングし、メモリと実行時間への影響を測定してください。これらの測定結果を提案されている SetPool/PooledSet の概念と比較し、プロジェクトのテストで測定可能な利点と安全な再利用動作が実証された場合にのみ、作業が完了したとみなしてください。
索引モデルが issue の本文から書いたものです。
説明
Dask is creating many small objects and not just for very large graphs but this is pretty much a built in thing. This is one of not the most prominent reason why dask was originally built as a "tuple of tuple of tuple ..." machinery. Even the scheduler internally only adopted the usage of custom classes only a couple of years back because instantiation can be very costly. However, modern python versions have gotten much better at managing overhead so this is negligible for most classes.
The one type of objects we're still affected by, both in terms of memory but also in terms of runtime are sets. Yes, sets! (I might share profiles but this is mostly an issue to preseve an idea). One way to work around instantiation cost of sets is to use an object pool design. Effectively, we'd "disable" garbage collection and would resurrect objects on finalization in a way that would allow us to reuse them.
A minimal version of this would look like that
import sys
class SetPool:
def __init__(self):
self._sets = []
def add(self, obj):
obj.clear()
self._sets.append(obj)
def get(self):
try:
new = self._sets.pop()
return new
except:
return None
def stored_size(self):
return sum(map(sys.getsizeof, self._sets))
globalpool = SetPool()
class PooledSet(set):
def __new__(cls, *iterables):
obj = globalpool.get()
if obj is not None:
return obj
return super().__new__(cls, *iterables)
def __del__(self):
print(f"Resurrecting {id(self)}")
globalpool.add(self)
This could be expanded on need, e.g. by hinting towards whether this would be an empty set, a very large set or a somewhat normal one.
Haven't tried out what the actual impact would be but it is a fun concept that could help if we actually want/need to optimize for this
- 主要言語
- Python
- スター
- 1.7k
- フォーク
- 778
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dask/distributed のほかの issue
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dask/distributed#9366 ·
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
dask/distributed#9353 ·
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
dask/distributed#8304 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
dask/distributed#4816 · コメント 2 件 ·
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
dask/distributed#2378 · コメント 2 件 ·
dask/distributed の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
spec-kitty/spec-kitty#5319 ·
メンテナーはふだん 1 日以内に返信
-
backend::vllm diffusion multimodal
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
openai/openai-agents-python#5229 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信