Skip to content

[Feat] Optimize ASU task manager with lock-free slots#980

Open
AooooooA-C wants to merge 1 commit into
ModelEngine-Group:feature_26h1from
AooooooA-C:asu-task-slots
Open

[Feat] Optimize ASU task manager with lock-free slots#980
AooooooA-C wants to merge 1 commit into
ModelEngine-Group:feature_26h1from
AooooooA-C:asu-task-slots

Conversation

@AooooooA-C

@AooooooA-C AooooooA-C commented May 27, 2026

Copy link
Copy Markdown
Contributor

Purpose

This PR replaces the mutex-protected unordered_map in TaskManagerBase with a fixed-size slot table based on open addressing and atomic state transitions. The goal is to reduce global lock contention.

Modifications

The original implementation:

std::mutex mu_;
std::unordered_map<TaskId, std::shared_ptr<Context>> tasks_;

is replaced by a fixed-size slot array:

std::vector<Slot> slots_;

Each slot stores:

state
task_id
ctx

Test

1. Create and enter the build directory

cd /YOURPATH/unified-cache-management
mkdir -p build && cd build

2. Configure CMake

cmake .. \
  -DBUILD_UCM_ASU=ON \
  -DBUILD_UNIT_TESTS=ON 
  -DBUILD_UCM_STORE=OFF \
  -DDOWNLOAD_DEPENDENCE=ON \
  -DRUNTIME_ENVIRONMENT=ascend

3. Build the asu.test target

cmake --build . --target asu.test -j$(nproc))

4. Run the tests

./ucm/transport/kv/asu/asu.test --gtest_also_run_disabled_tests --gtest_filter='TransportTaskManagerTest*:ClientTaskManagerTest*:TaskManagerBaseBench*:SlotTaskManagerBaseBench*'

5. Test Results

Unit tests for SlotTaskManagerBase verifying submit/get/remove/getAll correctness:
2026-06-05-task_manager_slot_test

Benchmark: TaskManagerBase (mutex + unordered_map) vs SlotTaskManagerBase (lock-free slots + IndexPool)
2026-06-05-task_manager_base_bench

@AooooooA-C AooooooA-C force-pushed the asu-task-slots branch 2 times, most recently from ccc6276 to f31431a Compare May 27, 2026 09:43
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h
@AooooooA-C AooooooA-C force-pushed the asu-task-slots branch 2 times, most recently from 78c673f to 07bcf88 Compare May 28, 2026 12:16
@ModelEngine-Group ModelEngine-Group deleted a comment from ygwpz May 29, 2026
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/test/case/task_manager_base_slot_test.cc
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
@AooooooA-C AooooooA-C force-pushed the asu-task-slots branch 2 times, most recently from 0aa5709 to 6ff7321 Compare June 1, 2026 10:18
Comment thread e -i HEAD~2 Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
Comment thread ucm/transport/kv/asu/common/task_manager_base.h Outdated
@AooooooA-C AooooooA-C force-pushed the asu-task-slots branch 2 times, most recently from 27dec4a to 1ef17e2 Compare June 5, 2026 06:37

@nrj868 nrj868 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants