-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Thread] Add thread local variable ThreadContext #7234
Conversation
25ed800
to
6153b53
Compare
6153b53
to
f2e2c08
Compare
2ac3493
to
2193b6d
Compare
1053895
to
b4adb7a
Compare
b4adb7a
to
44d9a33
Compare
be/src/runtime/thread_context.h
Outdated
// So, kudu Class-scoped static thread local implementation was introduced. Solve the above problem by | ||
// Thread-scopedthread local + Class-scoped thread local. | ||
// | ||
// This may look very track, but it's the best way I can find. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This may look very track, but it's the best way I can find. | |
// This may look very trick, but it's the best way I can find. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
be/src/runtime/thread_context.h
Outdated
public: | ||
explicit AttachTaskThread(const ThreadContext::TaskType& type, const std::string& task_id, | ||
const TUniqueId& fragment_instance_id) { | ||
DCHECK(task_id != "" && fragment_instance_id != TUniqueId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is not a query task , the fragment_instance_id
maybe empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this file is copied from other project, better add a comment.
Same as other file in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, in threadlocal.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
…he#7234) The thread context saves some info about a working thread. 1. thread_id: Current thread id, Auto generated. 2. type: The type is a enum value indicating which type of task current thread is running. For example: QUERY, LOAD, COMPACTION, ... 3. task id: A unique id to identify this task. maybe query id, load job id, etc. Using gcc11 compiles thread_local variable on lower versions of GLIBC will report an error, see apache#7911 This is very difficult to solve, so kudu Class-scoped static thread local implementation was introduced. Solve the above problem by Thread-scopedthread local + Class-scoped thread local. See the comments for ThreadContextPtr for details.
The thread context saves some info about a working thread. 1. thread_id: Current thread id, Auto generated. 2. type: The type is a enum value indicating which type of task current thread is running. For example: QUERY, LOAD, COMPACTION, ... 3. task id: A unique id to identify this task. maybe query id, load job id, etc. Using gcc11 compiles thread_local variable on lower versions of GLIBC will report an error, see #7911 This is very difficult to solve, so kudu Class-scoped static thread local implementation was introduced. Solve the above problem by Thread-scopedthread local + Class-scoped thread local. See the comments for ThreadContextPtr for details.
…he#7234) The thread context saves some info about a working thread. 1. thread_id: Current thread id, Auto generated. 2. type: The type is a enum value indicating which type of task current thread is running. For example: QUERY, LOAD, COMPACTION, ... 3. task id: A unique id to identify this task. maybe query id, load job id, etc. Using gcc11 compiles thread_local variable on lower versions of GLIBC will report an error, see apache#7911 This is very difficult to solve, so kudu Class-scoped static thread local implementation was introduced. Solve the above problem by Thread-scopedthread local + Class-scoped thread local. See the comments for ThreadContextPtr for details.
Proposed changes
The thread context saves some info about a working thread.
For example: QUERY, LOAD, COMPACTION, ...
Using gcc11 compiles thread_local variable on lower versions of GLIBC will report an error, see #7911
This is very difficult to solve, so kudu Class-scoped static thread local implementation was introduced. Solve the above problem by Thread-scopedthread local + Class-scoped thread local. See the comments for ThreadContextPtr for details.
Types of changes
What types of changes does your code introduce to Doris?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...