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

[PLAT-3941] Reduce metadata churn #924

Merged
merged 2 commits into from
Dec 4, 2020
Merged

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Dec 4, 2020

Goal

The metadata changed blocks were being called in cases where the data had not actually changed.

This is inefficient, particularly now that metadata is written to disk when it changes.

Changeset

The BugsnagMetadata class has been updated to only notify observers if the data has changed. This required adjustments to a few unit test cases that were relying on the old broken behaviour.

BugsnagClient has been updated to

  • stop adding itself as an observer twice
  • add app and device info before registering as an observer

Also uncovered a bug whereby the user information would not be written to disk - this was due to the use of the _user ivar.

Testing

Added a new unit test case to verify that observer is not called if data has not changed.

Manually tested using a sample app...

Before

2020-12-04 09:18:08.213933+0000 objective-c-osx[28729:1185082] metadata.json = {
}
2020-12-04 09:18:08.214373+0000 objective-c-osx[28729:1185082] config.json = {
    appVersion = "1.0";
    bundleVersion = 1;
    releaseStage = development;
}
2020-12-04 09:18:08.214765+0000 objective-c-osx[28729:1185082] state.json = {
}
2020-12-04 09:18:08.215201+0000 objective-c-osx[28729:1185082] metadata.json = {
}
2020-12-04 09:18:08.236219+0000 objective-c-osx[28729:1185082] metadata.json = {
    app =     {
        name = "objective-c-osx";
    };
}
2020-12-04 09:18:08.236677+0000 objective-c-osx[28729:1185082] metadata.json = {
    app =     {
        name = "objective-c-osx";
    };
}
2020-12-04 09:18:08.237120+0000 objective-c-osx[28729:1185082] metadata.json = {
    app =     {
        name = "objective-c-osx";
    };
    device =     {
        simulator = 0;
        timezone = GMT;
        wordSize = 64;
    };
}
2020-12-04 09:18:08.237552+0000 objective-c-osx[28729:1185082] metadata.json = {
    app =     {
        name = "objective-c-osx";
    };
    device =     {
        simulator = 0;
        timezone = GMT;
        wordSize = 64;
    };
}

After

2020-12-04 09:19:08.719311+0000 objective-c-osx[28960:1187203] metadata.json = {
    app =     {
        name = "objective-c-osx";
    };
    device =     {
        simulator = 0;
        timezone = GMT;
        wordSize = 64;
    };
}
2020-12-04 09:19:08.719858+0000 objective-c-osx[28960:1187203] config.json = {
    appVersion = "1.0";
    bundleVersion = 1;
    releaseStage = development;
}
2020-12-04 09:19:08.720317+0000 objective-c-osx[28960:1187203] state.json = {
}
2020-12-04 09:19:08.721029+0000 objective-c-osx[28960:1187203] state.json = {
    user =     {
        id = 93f3d632b7fcb0365071780cf1f3e6229c1be887;
    };
}

@nickdowell nickdowell force-pushed the nickdowell/reduce-metadata-churn branch from 2ad5a17 to a4b10c8 Compare December 4, 2020 10:44
@nickdowell nickdowell marked this pull request as ready for review December 4, 2020 12:51
@nickdowell nickdowell merged commit c9c7741 into next Dec 4, 2020
@nickdowell nickdowell deleted the nickdowell/reduce-metadata-churn branch December 4, 2020 14:32
@kstenerud kstenerud mentioned this pull request Dec 8, 2020
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