Extreme slow down when using Map#lock/unlock from multiple threads [API-1968]
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
まず、提供された Python 再現プログラムを 1 つの Hazelcast クライアント、複数のスレッド、および Map#lock/unlock を使って実行し、その後、ブロッキング map lock と lock、get、put、unlock 操作で使用されるクライアントパスを調査します。完了条件は、並行実行が逐次実行よりも大幅に遅くなる理由を特定し、報告されたワークロードでその遅延が発生しなくなったことを検証することです。
索引モデルが issue の本文から書いたものです。
説明
Running the Pessimistic Locking example from multiple threads using the same client takes vastly different amounts of time.
The sequential runs of the same code can give:
It took 68.364421721 second(s) to finish.
It took 2666.208992902 second(s) to finish.
Using one Hazelcast instance. The behaviour is reproducible on MacOS and Linux. Using python3
The code sample:
import hazelcast
from time import perf_counter
from concurrent.futures import ThreadPoolExecutor
from threading import Thread
if __name__ == "__main__":
client = hazelcast.client.HazelcastClient(
cluster_name="dev",
lifecycle_listeners=[
lambda state: print("Lifecycle event >>>", state),
]
)
# Defining send_query func and pooled_query func, to send requests using ThreadPoolExecutor
desired_range = range(10000)
desired_threads = 10
# Create a Distributed Map in the cluster
counter_map = client.get_map("counter-map").blocking()
counter_map.put("key", 0)
# Pesimistic Locking
def send_query(range_parameter):
for i in range_parameter:
counter_map.lock("key")
try:
counter = counter_map.get("key") + 1
counter_map.put("key", counter)
finally:
counter_map.unlock("key")
def pooled_query():
# create the thread pool
n_threads = desired_threads
with ThreadPoolExecutor(n_threads) as executor:
# push query for each thread
_ = [executor.submit(send_query, desired_range) for i in range(0, desired_threads)]
def pooled_query_thread():
threads = []
for i in range(desired_threads):
thread = Thread(target=send_query, args=(desired_range,))
threads.append(thread)
for thr in threads:
thr.start()
for thr in threads:
thr.join()
## Timer start
start = perf_counter()
## Invoke ThreadPoolExecutor to send requests
if __name__ == "__main__":
# pooled_query()
pooled_query_thread()
## Timer end
finish = perf_counter()
print(f'It took {finish-start} second(s) to finish.')
for key, value in counter_map.entry_set():
print(key, value)
client.shutdown()
- 主要言語
- Python
- スター
- 115
- フォーク
- 78
- 平均マージ
- 2日 23時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hazelcast/hazelcast-python-client のほかの issue
-
Type: Test-Failure
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Type: Test-Failure
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
asyncio Type: Test-Failure
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
asyncio to-jira Type: Test-Failure
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
hazelcast/hazelcast-python-client#761 · コメント 1 件 ·
-
asyncio to-jira Type: Test-Failure
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
hazelcast/hazelcast-python-client#760 · コメント 1 件 ·
hazelcast/hazelcast-python-client の issue をすべて見る
似ている issue
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
aws-samples/sample-spec-driven-presentation-maker#648 ·
メンテナーはふだん 1 日以内に返信
-
firestore: enable live window.yaml pipeline system tests once add_window_fields is in productionオープン
難易度 1/5 1時間未満 初心者へのやさしさ 64/100
googleapis/google-cloud-python#19115 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Feyisara2108/stellargive#1377 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信