Skip to content

Support custom ParkingLot number#3033

Merged
wwbmmm merged 3 commits intoapache:masterfrom
chenBright:parkinglot_num
Aug 18, 2025
Merged

Support custom ParkingLot number#3033
wwbmmm merged 3 commits intoapache:masterfrom
chenBright:parkinglot_num

Conversation

@chenBright
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: #2849 (comment)

Problem Summary:

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

@chenBright chenBright requested a review from Copilot July 19, 2025 14:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for configurable parking lot numbers per tag in the bthread system, replacing the hardcoded PARKING_LOT_NUM constant with a runtime configurable value. The changes enable users to customize the number of parking lots per tag through a new flag.

  • Removes hardcoded PARKING_LOT_NUM = 4 constant and replaces it with configurable _pl_num_of_each_tag
  • Adds new command-line flag bthread_parking_lot_of_each_tag to control parking lot count
  • Updates parking lot iteration logic to use the configurable value instead of hardcoded constant

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/bthread/task_control.h Removes hardcoded PARKING_LOT_NUM constant, renames member variable to _tagged_pl, and adds _pl_num_of_each_tag field
src/bthread/task_control.cpp Implements configurable parking lot logic using new flag and updates iteration patterns
src/bthread/bthread.cpp Defines new bthread_parking_lot_of_each_tag flag and contains unrelated namespace cleanup

Comment thread src/bthread/task_control.cpp Outdated
Comment thread src/bthread/task_control.cpp
Comment thread src/bthread/bthread.cpp
Comment thread src/bthread/task_control.h Outdated
@wwbmmm
Copy link
Copy Markdown
Contributor

wwbmmm commented Jul 21, 2025

LGTM

@yanglimingcn
Copy link
Copy Markdown
Contributor

一般parkinglot的数量和worker的数量,怎么样是比较合适的。

@yanglimingcn
Copy link
Copy Markdown
Contributor

LGTM

@chenBright
Copy link
Copy Markdown
Contributor Author

chenBright commented Jul 21, 2025

一般parkinglot的数量和worker的数量,怎么样是比较合适的。

可以调整为平均4/8个worker线程共享一个ParkingLot,在实际场景测试一下效果才能确定个数。

我们的场景是worker线程数多(200+)、大量轻量bthread,火焰图显示在ParkingLot futex内核自旋锁的操作消耗了过多的CPU。

@wwbmmm wwbmmm merged commit f949962 into apache:master Aug 18, 2025
15 checks passed
@chenBright chenBright deleted the parkinglot_num branch August 18, 2025 03:12
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