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

Snapshot diff merging fixes #174

Merged
merged 4 commits into from
Nov 12, 2021
Merged

Snapshot diff merging fixes #174

merged 4 commits into from
Nov 12, 2021

Conversation

Shillaker
Copy link
Collaborator

@Shillaker Shillaker commented Nov 11, 2021

These changes were part of the effort to get pthreads working in Faasm again. The original issue was an off-by-one error in the diff detection loop, but to make diagnosis simpler I refactored the diff detection logic.

Changes:

  • Move logic around working out dirty region offsets into new getDirtyRegions function. This is preferable to the old getDirtyPages which would return a list of page numbers that the diffing function eventually converted into regions. This logic is now isolated and tested separately.
  • Refactored diff detection loop to push all remaining logic down into the MergeRegion class (now all the grimness is held in once place 😄)
  • Allow Overwrite merge regions to specify length=0, which means they will extend to the end of the memory. This is necessary to merge back changes from memory allocated outside the original snapshot size.

@Shillaker Shillaker self-assigned this Nov 11, 2021
@Shillaker Shillaker marked this pull request as ready for review November 11, 2021 14:47
Copy link
Collaborator

@csegarragonz csegarragonz left a comment

Choose a reason for hiding this comment

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

LGTM, I am not even sure what I suggest is worth doing


if (p > 0 && dirtyPages.at(p - 1) == thisPageNum - 1) {
// Previous page was also dirty, just update last region
regions.back().second = thisPageEnd;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could regions here be empty, thus back() cause undefined behaviour?

I am aware this may not have sense logically, but maybe worth catching?

Copy link
Collaborator Author

@Shillaker Shillaker Nov 12, 2021

Choose a reason for hiding this comment

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

Yes good point, I'll add an assert as that empty back() problem can be hard to diagnose.

Actually, it's impossible for that to occur as the else branch of this if will always add the first element to the list.

@Shillaker Shillaker merged commit 41207d9 into master Nov 12, 2021
@Shillaker Shillaker deleted the reduction-fix branch November 12, 2021 08:42
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.

2 participants