Skip to content

Commit

Permalink
chunk id add lock
Browse files Browse the repository at this point in the history
  • Loading branch information
strint committed Oct 8, 2022
1 parent 8ca22bf commit 2adbb13
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions oneflow/core/memory/chunk_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void ChunkMgr::GetChunkProtosByMemZoneUniqueId(int64_t mem_zone_uid,
}

void ChunkMgr::AddChunkProto(const ChunkProto& chunk) {
std::unique_lock<std::mutex> guard(mutex_);

This comment has been minimized.

Copy link
@lixinqi

lixinqi Oct 8, 2022

Contributor

下面的FindOrCreateChunk是不是也需要加锁啊?

This comment has been minimized.

Copy link
@lixinqi

lixinqi Oct 8, 2022

Contributor

看起来上面的GetChunkProtosByMemZoneUniqueId需要加锁。

This comment has been minimized.

Copy link
@strint

strint Oct 9, 2022

Author Contributor

跑 100 次实验能发现找不到 chunk id 的问题,我把这两个函数也加上锁再看下

const int64_t mem_zone_uid = memory::GetUniqueMemCaseId(chunk.machine_id(), chunk.mem_case());
CHECK(
chunk_id2chunk_proto_.emplace(chunk.chunk_id(), std::make_unique<ChunkProto>(chunk)).second);
Expand Down

0 comments on commit 2adbb13

Please sign in to comment.