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

perf: use separate dropper thread for current_thread flavor #666

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

DDtKey
Copy link
Collaborator

@DDtKey DDtKey commented Jun 17, 2024

tokio::test uses current_thread flavor by default and it's typical use-case.

However, we need to perform some async operations on drop, and it used to spawn a new thread for each drop. It's inefficient and was a temporary solution.

Now, it uses:

  • for multi-thread runtime flavor: tokio::task::block_in_place
  • for current-thread runtime flavor: lazily spawns a separate thread for dropping tasks, thus it will be only 1 thread regardless of the number of containers, networks, etc.

`tokio::test` run with `current_thread` flavor by default and it's typical use-case.

However, we need to perform some async operations on drop, and it used to spawn a new thread for each drop. It's inefficient and was a temporary solution.

Now, it uses:
- for `multi-thread` runtime flavor: `tokio::task::block_in_place`
- for `current-thread` runtime flavor:  lazily spawns a separate thread for dropping tasks, thus it will be only 1 thread regardless of the number of containers, networks, etc.
Copy link

netlify bot commented Jun 17, 2024

Deploy Preview for testcontainers-rust ready!

Name Link
🔨 Latest commit 849b036
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-rust/deploys/667071bb95e19100087f6150
😎 Deploy Preview https://deploy-preview-666--testcontainers-rust.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DDtKey DDtKey merged commit e5217e3 into main Jun 17, 2024
13 checks passed
@DDtKey DDtKey deleted the perf/avoid-extra-threads-on-drop branch June 17, 2024 17:33
@github-actions github-actions bot mentioned this pull request Jun 27, 2024
DDtKey pushed a commit that referenced this pull request Jun 28, 2024
## 🤖 New release
* `testcontainers`: 0.18.0 -> 0.19.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.19.0] - 2024-06-27

### Details
#### Bug Fixes
- [❗] Use `rustls-tls` as default for `reqwest`
([#672](#672))

#### Documentation
- Update examples of `GenericImage::with_exposed_port`
([#670](#670))

#### Features
- Add ability to convert `ContainerPort` to `u16`
([#664](#664))

#### Miscellaneous Tasks
- Make `ports` module public
([#665](#665))

#### Performance
- Use separate dropper thread for `current_thread` flavor
([#666](#666))

#### Refactor
- Use multi-threaded runtime for blocking feature
([#667](#667))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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.

1 participant