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

Improve performance in ActiveStorage::Service::MirrorService #51740

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

heka1024
Copy link
Contributor

@heka1024 heka1024 commented May 5, 2024

Motivation / Background

This Pull Request has been created to remove FIXME comment of ActiveStorage::Service::MirrorService.

Detail

This Pull Request use thread pool to parallelize delete and delete_prefixed in ActiveStorage::Service::MirrorService.

Additional information

If this is a nit performance boost than complexity, how about remove comment?

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

activestorage/CHANGELOG.md Outdated Show resolved Hide resolved
@@ -30,6 +30,13 @@ def self.build(primary:, mirrors:, name:, configurator:, **options) # :nodoc:

def initialize(primary:, mirrors:)
@primary, @mirrors = primary, mirrors
@executor = Concurrent::ThreadPoolExecutor.new(
Copy link
Member

Choose a reason for hiding this comment

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

Can you do a performance benchmarking?

Copy link
Contributor Author

@heka1024 heka1024 May 5, 2024

Choose a reason for hiding this comment

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

Sure! I'll add performance benchmark and request review to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akhilgkrishnan
This is performance benchmark using GCS. In my opinion, there is a performance improvement when looking at real time.

  • repeat time: 10

  • Used service: Google Cloud Storage (region: ap-northeast-3)

  • Used image size: 512kb

  • primary: 1, mirrors: 2

Task Real Time User Time System Time Total Time
Parallel 0.453 0.055 0.015 0.070
Sequential 0.979 0.045 0.011 0.056
  • primary: 1, mirrors: 1
Task Real Time User Time System Time Total Time
Parallel 0.380 0.053 0.020 0.074
Sequential 0.624 0.033 0.008 0.041

Copy link
Contributor Author

@heka1024 heka1024 May 16, 2024

Choose a reason for hiding this comment

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

@akhilgkrishnan Could you please review when you get a chance? 😄

@heka1024 heka1024 force-pushed the parallel-upload-in-mirror-service branch from 00febe1 to ecfbb5e Compare May 5, 2024 15:12
…ervice#delete` and `ActiveStorage::Service::MirrorService#delete_prefixed`
@heka1024 heka1024 force-pushed the parallel-upload-in-mirror-service branch from ecfbb5e to 3f2258a Compare May 12, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants