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

enhance: async cgo utility #33133

Merged
merged 7 commits into from
Jun 9, 2024
Merged

Conversation

chyezh
Copy link
Contributor

@chyezh chyezh commented May 17, 2024

issue: #30926, #33132

  • implement future-based cgo utility.

@sre-ci-robot sre-ci-robot added size/XXL Denotes a PR that changes 1000+ lines. area/compilation labels May 17, 2024
@mergify mergify bot added dco-passed DCO check passed. kind/enhancement Issues or changes related to enhancement labels May 17, 2024
Copy link
Contributor

mergify bot commented May 17, 2024

@chyezh ut workflow job failed, comment rerun ut can trigger the job again.

Copy link
Contributor

mergify bot commented May 17, 2024

@chyezh E2e jenkins job failed, comment /run-cpu-e2e can trigger the job again.

Copy link
Contributor

mergify bot commented May 19, 2024

@chyezh ut workflow job failed, comment rerun ut can trigger the job again.

@chyezh chyezh force-pushed the feat_async_cgo branch 2 times, most recently from 4506cda to e22eca1 Compare May 19, 2024 15:23
Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 82.02247% with 64 lines in your changes missing coverage. Please review.

Project coverage is 81.38%. Comparing base (60baaed) to head (036a8ec).
Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #33133      +/-   ##
==========================================
+ Coverage   81.23%   81.38%   +0.15%     
==========================================
  Files        1029     1038       +9     
  Lines      132215   133169     +954     
==========================================
+ Hits       107399   108377     +978     
+ Misses      20766    20725      -41     
- Partials     4050     4067      +17     
Files Coverage Δ
internal/core/src/common/EasyAssert.h 83.33% <100.00%> (-0.88%) ⬇️
internal/util/cgo/errors.go 100.00% <100.00%> (ø)
internal/util/cgo/futures_test_case.go 100.00% <100.00%> (ø)
internal/util/cgo/options.go 100.00% <100.00%> (ø)
internal/util/cgo/pool.go 100.00% <100.00%> (ø)
internal/util/cgo/state.go 100.00% <100.00%> (ø)
pkg/util/merr/errors.go 86.95% <ø> (ø)
internal/core/src/futures/Ready.h 96.29% <96.29%> (ø)
internal/util/cgo/futures.go 98.48% <98.48%> (ø)
internal/util/cgo/manager_active.go 94.44% <94.44%> (ø)
... and 6 more

... and 234 files with indirect coverage changes

@chyezh chyezh force-pushed the feat_async_cgo branch 2 times, most recently from 6d7e8cb to de513be Compare May 20, 2024 06:56
Copy link
Contributor

mergify bot commented May 20, 2024

@chyezh ut workflow job failed, comment rerun ut can trigger the job again.

@mergify mergify bot added needs-dco DCO is missing in this pull request. and removed dco-passed DCO check passed. labels May 20, 2024
Copy link
Contributor

mergify bot commented May 20, 2024

@chyezh Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify mergify bot added dco-passed DCO check passed. and removed needs-dco DCO is missing in this pull request. labels May 20, 2024
Copy link
Contributor

mergify bot commented May 20, 2024

@chyezh ut workflow job failed, comment rerun ut can trigger the job again.

Copy link
Contributor

mergify bot commented May 20, 2024

@chyezh E2e jenkins job failed, comment /run-cpu-e2e can trigger the job again.

Copy link
Contributor

mergify bot commented May 20, 2024

@chyezh ut workflow job failed, comment rerun ut can trigger the job again.

Copy link
Contributor

mergify bot commented May 27, 2024

@chyezh ut workflow job failed, comment rerun ut can trigger the job again.

@chyezh chyezh force-pushed the feat_async_cgo branch 2 times, most recently from de94aa1 to a0f98ef Compare May 27, 2024 08:44
@chyezh
Copy link
Contributor Author

chyezh commented May 27, 2024

rerun ut

1 similar comment
@chyezh
Copy link
Contributor Author

chyezh commented May 27, 2024

rerun ut

num_threads,
std::make_unique<folly::PriorityLifoSemMPMCQueue<
folly::CPUThreadPoolExecutor::CPUTask,
folly::QueueBehaviorIfFull::BLOCK>>(num_priority,
Copy link
Contributor

Choose a reason for hiding this comment

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

this might be the reason thread will increase.

might be reasonable to throw error under queue full?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • number of threads is fixed, not increase in pool.
  • current behaviour is blocked if queue is full, these will cause a long cgo calling.
  • throwing handling will increase the code complexity, it should collaborate with go-side to avoid the queue is full.

state: newFutureState(),
}

runtime.SetFinalizer(future, func(future *futureImpl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need finalizer?
could we can handle future destroy in the select loop?

Copy link
Contributor

Choose a reason for hiding this comment

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

cancel and destroy might be happen in the same call?

Copy link
Contributor Author

@chyezh chyezh Jun 5, 2024

Choose a reason for hiding this comment

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

  • destroy is just a light-weight destruction of C-side, I think it's ok to set it as a finializer to avoid resource leak.
  • cancel just notify the underlying cancellation token, destroy can be only called if the underlying task is done. So cannot merge it together.

}

func (f *futureImpl) BlockAndLeakyGet() (unsafe.Pointer, error) {
f.blockUntilReady()
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, blockUntil ready and future leak get and get and be one cgo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • blockUntilready can be called multiple times, but leakyget can be only call once. It's better to implement two method to perform a future-like api.
  • we cannot merge it together, there are always two cgo call will be applied future_go_register_ready_callback, ``future_leak_and_get` to avoid long cgo call.

Copy link
Contributor

mergify bot commented Jun 7, 2024

@chyezh E2e jenkins job failed, comment /run-cpu-e2e can trigger the job again.

@xiaofan-luan
Copy link
Contributor

/lgtm
/approve

@sre-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chyezh, xiaofan-luan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit f53ab54 into milvus-io:master Jun 9, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/compilation ci-passed dco-passed DCO check passed. kind/enhancement Issues or changes related to enhancement lgtm size/XXL Denotes a PR that changes 1000+ lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants