Skip to content
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

Use thread-safe cache in thread_local_caching_allocator #6539

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Pansysk75
Copy link
Member

No description provided.

@StellarBot
Copy link

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each------

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-07T00:47:36+00:00
HPX Commitd27ac2ee972af2
Clusternamerostamrostam
Datetime2024-03-18T09:18:04.949759-05:002024-09-06T19:55:11.519858-05:00
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Envfile

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch--

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-07T00:47:36+00:00
HPX Commitd27ac2ee972af2
Clusternamerostamrostam
Datetime2024-03-18T09:19:53.062988-05:002024-09-06T19:57:01.633845-05:00
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Envfile

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add------
Stream Benchmark - Scale-------
Stream Benchmark - Triad------
Stream Benchmark - Copy------

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-07T00:47:36+00:00
HPX Commitd27ac2ee972af2
Clusternamerostamrostam
Datetime2024-03-18T09:20:13.002391-05:002024-09-06T19:57:19.484829-05:00
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Envfile

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@Pansysk75 Pansysk75 force-pushed the fix-thread-local-caching-allocator branch from 30370cb to 5ed299c Compare September 7, 2024 22:36
@StellarBot
Copy link

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each------

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-07T22:36:42+00:00
HPX Commitd27ac2eb751e72
Clusternamerostamrostam
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5
Envfile
Datetime2024-03-18T09:18:04.949759-05:002024-09-07T17:45:10.927119-05:00
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch--

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-07T22:36:42+00:00
HPX Commitd27ac2eb751e72
Clusternamerostamrostam
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5
Envfile
Datetime2024-03-18T09:19:53.062988-05:002024-09-07T17:47:00.957806-05:00
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add------
Stream Benchmark - Scale-------
Stream Benchmark - Triad------
Stream Benchmark - Copy------

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-07T22:36:42+00:00
HPX Commitd27ac2eb751e72
Clusternamerostamrostam
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5
Envfile
Datetime2024-03-18T09:20:13.002391-05:002024-09-07T17:47:18.556829-05:00
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

Copy link

codacy-production bot commented Sep 8, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.07% 88.89%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d9b5f6c) 223405 190053 85.07%
Head commit (c008395) 191295 (-32110) 162869 (-27184) 85.14% (+0.07%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6539) 9 8 88.89%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

hkaiser
hkaiser previously approved these changes Sep 9, 2024
Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

The remaining problems are unrelated. LGTM! Thanks!

@StellarBot
Copy link

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each------

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-09T17:15:16+00:00
HPX Commitd27ac2eed89bf1
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Clusternamerostamrostam
Envfile
Datetime2024-03-18T09:18:04.949759-05:002024-09-09T12:25:01.395820-05:00
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch--

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-09T17:15:16+00:00
HPX Commitd27ac2eed89bf1
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Clusternamerostamrostam
Envfile
Datetime2024-03-18T09:19:53.062988-05:002024-09-09T12:26:52.095834-05:00
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add------
Stream Benchmark - Scale-------
Stream Benchmark - Triad------
Stream Benchmark - Copy------

Info

PropertyBeforeAfter
HPX Datetime2024-03-18T14:00:30+00:002024-09-09T17:15:16+00:00
HPX Commitd27ac2eed89bf1
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Clusternamerostamrostam
Envfile
Datetime2024-03-18T09:20:13.002391-05:002024-09-09T12:27:09.764152-05:00
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@hkaiser
Copy link
Member

hkaiser commented Sep 9, 2024

@Pansysk75 we still have the circular dependency between the concurrency and allocator modules. Also, some of the header tests are failing (most likely caused by the circular dependency issue)

@Pansysk75
Copy link
Member Author

Pansysk75 commented Sep 9, 2024

@Pansysk75 we still have the circular dependency between the concurrency and allocator modules. Also, some of the header tests are failing (most likely caused by the circular dependency issue)

Hmm I suppose that means the allocator_support module is higher in the module hierarchy than the concurrency module?
I'm not exactly sure what fixing this would involve.

Oh, also, we should probably make all accesses to members of allocated_cache thread safe... Not sure why I ignored that. Also, this now makes me dislike this solution even more.

I opened an issue #6540 to document this.

@hkaiser
Copy link
Member

hkaiser commented Sep 9, 2024

@Pansysk75 we still have the circular dependency between the concurrency and allocator modules. Also, some of the header tests are failing (most likely caused by the circular dependency issue)

Hmm I suppose that means the allocator_support module is higher in the module hierarchy than the concurrency module? I'm not exactly sure what fixing this would involve.

The concurrency module is higher up in the hierarchy, see: https://hpx-docs.stellar-group.org/latest/report/v1.10.0/core/allocator_support.html

Oh, also, we should probably make all accesses to members of allocated_cache thread safe... Not sure why I ignored that. Also, this now makes me dislike this solution even more.

Yes, the deallocated and allocated members should be atomic. But we should combine both variables into one counter for that.

I opened an issue #6540 to document this.

Thanks!

@hkaiser hkaiser force-pushed the fix-thread-local-caching-allocator branch from 459cf67 to bd454ff Compare September 11, 2024 23:01
@StellarBot
Copy link

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each------

Info

PropertyBeforeAfter
HPX Commitd27ac2e3c74e4b
HPX Datetime2024-03-18T14:00:30+00:002024-09-11T23:01:22+00:00
Envfile
Datetime2024-03-18T09:18:04.949759-05:002024-09-11T18:42:36.321504-05:00
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch--

Info

PropertyBeforeAfter
HPX Commitd27ac2e3c74e4b
HPX Datetime2024-03-18T14:00:30+00:002024-09-11T23:01:22+00:00
Envfile
Datetime2024-03-18T09:19:53.062988-05:002024-09-11T18:44:26.972373-05:00
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add------
Stream Benchmark - Scale------
Stream Benchmark - Triad------
Stream Benchmark - Copy-------

Info

PropertyBeforeAfter
HPX Commitd27ac2e3c74e4b
HPX Datetime2024-03-18T14:00:30+00:002024-09-11T23:01:22+00:00
Envfile
Datetime2024-03-18T09:20:13.002391-05:002024-09-11T18:44:44.719698-05:00
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

Copy link

codacy-production bot commented Sep 12, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.07% 84.21%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d9b5f6c) 223405 190053 85.07%
Head commit (f8d92b0) 191295 (-32110) 162869 (-27184) 85.14% (+0.07%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6539) 38 32 84.21%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@hkaiser hkaiser force-pushed the fix-thread-local-caching-allocator branch from bd454ff to f8d92b0 Compare September 12, 2024 16:43
@StellarBot
Copy link

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each------

Info

PropertyBeforeAfter
HPX Commitd27ac2e1bb0796
HPX Datetime2024-03-18T14:00:30+00:002024-09-12T16:43:09+00:00
Clusternamerostamrostam
Envfile
Datetime2024-03-18T09:18:04.949759-05:002024-09-12T11:50:01.583868-05:00
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch--

Info

PropertyBeforeAfter
HPX Commitd27ac2e1bb0796
HPX Datetime2024-03-18T14:00:30+00:002024-09-12T16:43:09+00:00
Clusternamerostamrostam
Envfile
Datetime2024-03-18T09:19:53.062988-05:002024-09-12T11:51:51.740992-05:00
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add------
Stream Benchmark - Scale-----
Stream Benchmark - Triad------
Stream Benchmark - Copy------

Info

PropertyBeforeAfter
HPX Commitd27ac2e1bb0796
HPX Datetime2024-03-18T14:00:30+00:002024-09-12T16:43:09+00:00
Clusternamerostamrostam
Envfile
Datetime2024-03-18T09:20:13.002391-05:002024-09-12T11:52:09.519499-05:00
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/13.0.1/bin/clang++ 13.0.1/opt/apps/llvm/18.1.5/bin/clang++ 18.1.5

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@hkaiser
Copy link
Member

hkaiser commented Sep 13, 2024

@Pansysk75 I think this is good to go as a stop-gap measure circumventing the underlying problem from happening. What do you think?

@Pansysk75
Copy link
Member Author

Pansysk75 commented Sep 13, 2024

@Pansysk75 I think this is good to go as a stop-gap measure circumventing the underlying problem from happening. What do you think?

Sure, one last thing, why is this check implemented like that? Our underlying data structure has a .size() member function, is it any different to use that?

void deallocate(pointer p, size_type n) noexcept
{
data.push(std::make_pair(p, n));
if (++deallocated > 2 * (allocated + 16))
{
clear_cache();
allocated = 0;
deallocated = 0;
}
}

@hkaiser hkaiser force-pushed the fix-thread-local-caching-allocator branch 3 times, most recently from fc10910 to a3e95e9 Compare September 17, 2024 00:31
@hkaiser hkaiser force-pushed the fix-thread-local-caching-allocator branch 3 times, most recently from 73abaa9 to 6478b44 Compare September 21, 2024 19:58
{
throw std::bad_array_new_length();
}
return cache().allocate(n);

auto [p, _] = detail::allocate_from_cache(num_cache);

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable _ is not used.
@hkaiser hkaiser force-pushed the fix-thread-local-caching-allocator branch 4 times, most recently from 5e3c656 to e12bc1c Compare September 25, 2024 19:12
@hkaiser hkaiser force-pushed the fix-thread-local-caching-allocator branch from e12bc1c to 64988ae Compare September 25, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants