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

RFC-4638: Executor #4638

Merged
merged 9 commits into from
May 27, 2024
Merged

RFC-4638: Executor #4638

merged 9 commits into from
May 27, 2024

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented May 23, 2024

Add executor in opendal to allow running tasks concurrently in background.

+ let exec = Executor::new();
  let w = op
      .writer_with(path)
      .chunk(8 * 1024 * 1024) // 8 MiB per chunk
      .concurrent(16) // 16 concurrent tasks
+     .executor(exec) // Use specified executor
      .await?;

Signed-off-by: Xuanwo <github@xuanwo.io>
@Xuanwo Xuanwo changed the title feat: Executor RFC-4638: Executor May 23, 2024
Signed-off-by: Xuanwo <github@xuanwo.io>
@Xuanwo Xuanwo marked this pull request as ready for review May 24, 2024 03:14
Signed-off-by: Xuanwo <github@xuanwo.io>
@hzxa21
Copy link

hzxa21 commented May 24, 2024

Thanks for proposing the RFC. This is very useful to our use case.

I have two questions:

  1. When the task fails during execution, will the opendal retry layer (if specified) take effect?
  2. When the task takes too long, will the opendal timeout layer (if specified) take effect?

@Xuanwo
Copy link
Member Author

Xuanwo commented May 24, 2024

  1. When the task fails during execution, will the opendal retry layer (if specified) take effect?

Yes. Failed task will be re-created and re-executed.

  1. When the task takes too long, will the opendal timeout layer (if specified) take effect?

Sadly, timeout layer can't control the task managed by executor. One possible workaround is users wrap the future with their own timeout. I'm still working on better solutions.

@Xuanwo
Copy link
Member Author

Xuanwo commented May 25, 2024

Sadly, timeout layer can't control the task managed by executor. One possible workaround is users wrap the future with their own timeout. I'm still working on better solutions.

Aha, I got an idea of how to fix it. TimeoutLayer will inject the timeout directly into the OpWrite. So the answer is YES. All layers will work.

@Xuanwo
Copy link
Member Author

Xuanwo commented May 25, 2024

cc @tisonkun, would you like to take a review of this RFC?

@tisonkun
Copy link
Member

@Xuanwo OK. I'll review this today.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

LGTM.

I suggest you to take a look at async-executor's design and see if we can reuse the abstraction at some level.

There is also executor-trait that can be helpful.

Xuanwo and others added 3 commits May 26, 2024 02:48
Co-authored-by: tison <wander4096@gmail.com>
Signed-off-by: Xuanwo <github@xuanwo.io>
Signed-off-by: Xuanwo <github@xuanwo.io>
@tisonkun
Copy link
Member

LGTM.

@Xuanwo Xuanwo merged commit b248bd5 into main May 27, 2024
230 of 233 checks passed
@Xuanwo Xuanwo deleted the rfc-executor branch May 27, 2024 07:00
George-Miao pushed a commit to George-Miao/opendal that referenced this pull request Jun 5, 2024
* feat: Executor

Signed-off-by: Xuanwo <github@xuanwo.io>

* Update

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix spelling

Signed-off-by: Xuanwo <github@xuanwo.io>

* Update tracking issues

Signed-off-by: Xuanwo <github@xuanwo.io>

* Update 4638_executor.md

Co-authored-by: tison <wander4096@gmail.com>

* Polish code example

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
Co-authored-by: tison <wander4096@gmail.com>
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.

None yet

4 participants