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

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')

TrueBrain
TrueBrain previously approved these changes Sep 5, 2021
@@ -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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fixed now.

Fixes performance issues with dependency lookup when retrieving
content list from the content server.
@TrueBrain TrueBrain merged commit 6e3d023 into OpenTTD:master Sep 9, 2021
@JGRennison JGRennison deleted the fix-9535 branch January 9, 2024 19:19
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.

None yet

3 participants