Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[BUGFIX] Fix race condition in kvstore.pushpull #17007

Merged
merged 5 commits into from
Dec 11, 2019

Conversation

eric-haibin-lin
Copy link
Member

Description

There was a race condition in the previous implementation for the pushpull API. We have to add stored.WaitToRead() before sending it back to workers.
@anandj91

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • [] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • [ x To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

server->Response(req);
}
update_buf->request.clear();
if (has_multi_precision_copy(type)) CopyFromTo(stored, store_[key]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract these two lines out of the if and else block since it is called in both conditions.

Copy link
Member Author

Choose a reason for hiding this comment

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

The order is different. In this branch, it is done after Response with ACK so that we send back message as early as possible. We then push to engine to perform copy.
For the previous case, we need to response with real data instead of ACK, we actually need to perform copy first.

}
if (has_pull) {
// if there is a pull request, perform WaitToRead() once before DefaultStorageResponse
if (has_multi_precision_copy(type)) CopyFromTo(stored, store_[key]);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it's better to move the CopyFromTo() into a different line and add braces around the if block.

Copy link
Member Author

Choose a reason for hiding this comment

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

In general we follow google's cpp style guide. For this case we inline the short statement to improve readability. https://google.github.io/styleguide/cppguide.html#Conditionals

Copy link
Contributor

@apeforest apeforest left a comment

Choose a reason for hiding this comment

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

LGTM

@eric-haibin-lin eric-haibin-lin merged commit 05af5c4 into apache:master Dec 11, 2019
@eric-haibin-lin eric-haibin-lin deleted the pushpull branch December 12, 2019 00:15
ptrendx pushed a commit to ptrendx/mxnet that referenced this pull request Dec 12, 2019
* add back gluon test

* fix typo

* change back gpu ctx

* also handle the case there some are pull and some are pushpull

* fix typo
@ptrendx ptrendx mentioned this pull request Dec 12, 2019
eric-haibin-lin pushed a commit that referenced this pull request Dec 12, 2019
* add back gluon test

* fix typo

* change back gpu ctx

* also handle the case there some are pull and some are pushpull

* fix typo
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants