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

Fix #9535: Maintain a reverse dependency map of network content #9538

Merged
merged 1 commit into from Sep 9, 2021

Conversation

@JGRennison
Copy link
Contributor

@JGRennison JGRennison commented Sep 4, 2021

Motivation / Problem

This fixes the performance issues in #9535 with dependency lookup when retrieving the content list from the content server.

Description

Instead of iterating all content to find reverse dependencies, maintain an iteratively built reverse dependency map.
When a new content item arrives, instead of calling CheckDependencyState on all content items, only call it on the reverse tree dependencies of the newly received item.

Limitations

N/A

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')
@@ -82,6 +84,7 @@ class ClientNetworkContentSocketHandler : public NetworkContentSocketHandler, Co
bool Receive_SERVER_CONTENT(Packet *p) override;

ContentInfo *GetContent(ContentID cid);
const ContentInfo *GetContent(ContentID cid) const { return const_cast<ClientNetworkContentSocketHandler *>(this)->GetContent(cid); }
Copy link
Member

@LordAro LordAro Sep 7, 2021

Choose a reason for hiding this comment

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

Unless I'm missing something obvious, the existing GetContent method doesn't make any changes to the object and can be declared const without making this hacky extra function

Loading

Copy link
Contributor Author

@JGRennison JGRennison Sep 7, 2021

Choose a reason for hiding this comment

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

That's fixed now.

Loading

Fixes performance issues with dependency lookup when retrieving
content list from the content server.
LordAro
LordAro approved these changes Sep 7, 2021
@TrueBrain TrueBrain merged commit 6e3d023 into OpenTTD:master Sep 9, 2021
16 checks passed
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants