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

Make few tasks #184

Merged
merged 1 commit into from
Jul 30, 2022
Merged

Make few tasks #184

merged 1 commit into from
Jul 30, 2022

Conversation

MBkkt
Copy link
Member

@MBkkt MBkkt commented Jul 18, 2022

Purpose

  • Remove atomic counter in shared state (we can use our state machine to determine when we need to remove it). atomic counter increment/decrement have a big cost in some scenarios
  • Decrease size of Future shared state to make it allocation cheaper
  • Some refactoring
  • Few fixes
  • Fix macOS and Windows CI
  • Add gcc-12 to CI

Related Information

  • Design document:
  • Bench PR: ...

Testing

  • This change is a trivial rework or code cleanup without any test coverage.
  • This change is already covered by existing tests.
  • This PR adds tests that were used to verify all changes.
  • There are tests in an external testing repository: ...

@coveralls
Copy link

coveralls commented Jul 19, 2022

Pull Request Test Coverage Report for Build 2763811443

  • 313 of 313 (100.0%) changed or added relevant lines in 41 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2565529157: 0.0%
Covered Lines: 1361
Relevant Lines: 1361

💛 - Coveralls

@codecov
Copy link

codecov bot commented Jul 19, 2022

Codecov Report

Merging #184 (3df3aa1) into main (1284ef5) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 3df3aa1 differs from pull request most recent head 21b3036. Consider uploading reports for the commit 21b3036 to get more accurate results

@@            Coverage Diff            @@
##              main      #184   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           57        60    +3     
  Lines         1348      1361   +13     
=========================================
+ Hits          1348      1361   +13     
Impacted Files Coverage Δ
include/yaclib/algo/when_all.hpp 100.00% <ø> (ø)
include/yaclib/algo/when_any.hpp 100.00% <ø> (ø)
include/yaclib/async/detail/base_core.hpp 100.00% <ø> (ø)
include/yaclib/async/run.hpp 100.00% <ø> (ø)
include/yaclib/coroutine/detail/on_awaiter.hpp 100.00% <ø> (ø)
include/yaclib/util/detail/nope_counter.hpp 100.00% <ø> (ø)
include/yaclib/util/detail/shared_func.hpp 100.00% <ø> (ø)
include/yaclib/util/intrusive_ptr.hpp 100.00% <ø> (ø)
src/executor/inline.cpp 100.00% <ø> (ø)
src/executor/manual.cpp 100.00% <ø> (ø)
... and 54 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@MBkkt MBkkt self-assigned this Jul 19, 2022
@MBkkt MBkkt assigned MBkkt and unassigned MBkkt Jul 29, 2022
@MBkkt MBkkt force-pushed the add-task2-rebase branch 5 times, most recently from 305e030 to 1a1def5 Compare July 29, 2022 20:54
@MBkkt MBkkt added devops DevOps tasks performance Improve performance refactoring Refactoring labels Jul 29, 2022
@MBkkt MBkkt assigned MBkkt and unassigned MBkkt Jul 29, 2022
@MBkkt MBkkt force-pushed the add-task2-rebase branch 2 times, most recently from fa8057a to a3a5359 Compare July 29, 2022 23:55
* Remove atomic counter in shared state (we can use our state machine to determine when we need to remove it). atomic counter increment/decrement have a big cost in some scenarios
* Decrease size of Future shared state to make it allocation cheaper
* Some refactoring
* Few fixes
* Fix macOS and Windows CI
* Add gcc-12 to CI
@MBkkt MBkkt force-pushed the add-task2-rebase branch 2 times, most recently from ea5782a to 21b3036 Compare July 30, 2022 00:16
YACLIB_ASSERT(std::exchange(_caller, &kEmptyRef) != nullptr);
caller->DecRef();
// auto expected = _callback.load(std::memory_order_acquire);
// if (expected == kEmpty || (expected & kMask) == kWaitNope) {
Copy link
Member Author

@MBkkt MBkkt Jul 30, 2022

Choose a reason for hiding this comment

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

Hmm I think it can be checked like ((expected & kMask) & ~kWaitNope) == 0?

I don't sure about will it better ot not.
Now we are always have 1 exchange + 1 load + optional(check load) cas

If here will be cas will be 2 load + 2 optional(check load) cas (1-2), I don't think it's definitely better so needs benchmark

I think on x86 current code will be better but for arm maybe 2 cas better, especially if compiler remove unnecessary loads

Copy link
Member Author

Choose a reason for hiding this comment

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

No, have here cas instead of exchange definitely bad idea because we need cycle for timed wait case

@MBkkt MBkkt assigned MBkkt and unassigned MBkkt Jul 30, 2022
@MBkkt MBkkt merged commit 16d8857 into main Jul 30, 2022
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
# TODO(MBkkt) https://github.com/msys2/setup-msys2?
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to create issue

_executor->Submit(callback);
#ifdef YACLIB_LOG_DEBUG
BaseCore::~BaseCore() noexcept {
YACLIB_ASSERT(_caller == &kEmptyRef);
Copy link
Member Author

Choose a reason for hiding this comment

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

add more asserts

#endif

yaclib_std::atomic_uint64_t _callback;
IRef* _caller{nullptr};
Copy link
Member Author

Choose a reason for hiding this comment

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

remove default initialize

IExecutor* BaseCore::GetExecutor() const noexcept {
return _executor.Get();
bool BaseCore::SetWait(IRef& callback, State state) noexcept {
// YACLIB_ASSERT(state == kWaitNope);
Copy link
Member Author

Choose a reason for hiding this comment

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

remove comment

}

IExecutor* BaseCore::GetExecutor() const noexcept {
return _executor.Get();
bool BaseCore::SetWait(IRef& callback, State state) noexcept {
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe we can remove virtual call for waiters

case kHereCall: {
auto* callback = reinterpret_cast<IRef*>(expected & ~kMask);
YACLIB_ASSERT(callback != nullptr);
Submit(static_cast<BaseCore&>(*callback), state);
Copy link
Member Author

Choose a reason for hiding this comment

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

InlineCore&

@@ -31,7 +33,7 @@ class SafeCall {
}

private:
Store _func;
[[no_unique_address]] Store _func;
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe make macro to prevent unknown attribute warning

template <typename Func>
Job* MakeUniqueJob(Func&& f) {
return new UniqueJob<Func>{std::forward<Func>(f)};
return new UniqueJob<decltype(std::forward<Func>(f))>{std::forward<Func>(f)};
Copy link
Member Author

Choose a reason for hiding this comment

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

<Func&&>

@@ -0,0 +1,95 @@
#pragma once
Copy link
Member Author

Choose a reason for hiding this comment

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

remove or implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops DevOps tasks performance Improve performance refactoring Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants