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 controller's os.RemoveAll single-threaded #5217

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Sep 18, 2024

What this PR does / why we need it:

This PR modifies the planner/scheduler cleanup to be single-threaded in order to reduce the file IO loads.
I did a load test with the following scenario and discovered that os.RemoveAll creates a high load for piped:

  • A single piped instance manages 400 apps
  • All 400 apps are triggered by one commit

In this scenario, the piped requires about 20 minutes to complete all deployments.
After this PR, the piped requires about 15 minutes to complete.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?: Yes

  • How are users affected by this change:

    • The piped requires larger disk space.
    • The piped performance becomes better
  • Is this breaking change:

  • How to migrate (if breaking change):

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Project coverage is 22.81%. Comparing base (5b9d417) to head (efa4e6d).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/app/piped/controller/controller.go 0.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5217      +/-   ##
==========================================
- Coverage   22.83%   22.81%   -0.03%     
==========================================
  Files         420      420              
  Lines       45302    45316      +14     
==========================================
- Hits        10344    10338       -6     
- Misses      34163    34183      +20     
  Partials      795      795              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

Thank you for the fix! I left a comment.

Comment on lines +229 to +230
go func() {
for ws := range c.workingDirRemovalCh {
Copy link
Member

Choose a reason for hiding this comment

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

[Ask] It looks like there is nothing to close c.workingDirRemovalCh. Does this lead to the goroutine leak?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if we would call this pattern a goroutine leak.
This goroutine's lifetime is the same as that of the piped.
As there is only one controller for each piped, there is also only one instance of this goroutine.
I believe this code is acceptable because the number of goroutines doesn't increase.

Copy link
Member

Choose a reason for hiding this comment

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

@Warashi

This goroutine's lifetime is the same as that of the piped.
As there is only one controller for each piped, there is also only one instance of this goroutine.

I see. I got your point 👍
But I think it would be better to make the lifetime of the channel explicit.

It would be better for the person calling controller.Run to not be aware of that.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be better for the person calling controller.Run to not be aware of that.

I got your point. I'll try to make the lifetime explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in this commit
efa4e6d

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Warashi Warashi merged commit 65c98a6 into master Sep 24, 2024
15 of 17 checks passed
@Warashi Warashi deleted the controller-cleanup-single-threaded branch September 24, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants