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

add batching to Copilot::Sync #1236

Merged
merged 1 commit into from
Oct 19, 2018
Merged

add batching to Copilot::Sync #1236

merged 1 commit into from
Oct 19, 2018

Conversation

utako
Copy link
Contributor

@utako utako commented Oct 17, 2018

  • A short explanation of the proposed change:

    Add batching to Copilot::Sync per our discussion with @tcdowney and @cwlbraa

    • Copilot::Sync only batches queries to the database.
    • It does not send batched resources to Copilot. Sending batched resources will be a bigger change and will be considered in the future.

[#161293119]

  • An explanation of the use cases your change solves

    When there are hella routes, route mappings and processes, database queries should be less expensive

  • Links to any other associated PRs
    Check for nil entries in bulk sync call #1227

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the master branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Copilot::Sync only batches queries to the database.
It does not send batched resources to Copilot. Sending
batched resources will be a bigger change and will be
considered in the future.

[#161293119]

Co-authored-by: Utako Ueda <uueda@pivotal.io>
@cfdreddbot
Copy link

Hey utako!

Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA.

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/161301937

The labels on this github issue will be updated when the story is started.

@infews
Copy link
Contributor

infews commented Oct 18, 2018

Did you take a look at the SequelPaginator? Sequel's datasets allow walking a query in pages/batches like you built up here.

@utako
Copy link
Contributor Author

utako commented Oct 18, 2018

Did you take a look at the SequelPaginator? Sequel's datasets allow walking a query in pages/batches like you built up here.

@infews No, but that looks appropriate. We wanted to adhere to the same querying pattern that was built in the Sync queries for tasks and LRPs. We could submit another PR to convert this and the rest of the batched queries to use the SequelPaginator for consistency. Happy for CAPI to do it, too. 😄

@infews
Copy link
Contributor

infews commented Oct 18, 2018

@tcdowney What do you think about @utako 's comment about query consistency?

@charleshansen
Copy link
Contributor

tldr, we could maybe make improvements, but I think we should merge the PR.

I looked at it again, you wouldn't actually use the SequelPaginator itself, but the query would be simpler to read if you used the Sequel pagination extension, like https://github.com/cloudfoundry/cloud_controller_ng/blob/master/lib/cloud_controller/paging/sequel_paginator.rb#L12. On the other hand, it does make sense for the syncers to use the same batching strategy, as Utako said.

At this point, the benefit of any further refactoring is questionable and we should merge the PR unless there are other objections (I'm cool with the Proc usage at this point). If we decide we want to use sequel for pagination, we should do it everywhere and not just right here. That larger question can be discussed outside of this PR.

Waiting for a +1 before actually merging...

@tcdowney
Copy link
Member

+1 to what @charleshansen said above. I think the Sequel Paginator suggestion that @infews had might be something we (CAPI) look into using across the sync jobs eventually, but not something I'd want to block this PR on (or would expect the Routing team to take on).

Looks good to me!

@tcdowney tcdowney merged commit adc4dd5 into cloudfoundry:master Oct 19, 2018
@utako utako deleted the batch_copilot_sync branch October 19, 2018 16:28
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.

7 participants