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

Cache item info, reducing time of crafting filter d: to ~32% #78945

Merged
merged 2 commits into from
Jan 5, 2025

Conversation

Brambor
Copy link
Contributor

@Brambor Brambor commented Jan 4, 2025

Summary

Performance "Cache item info, reducing time of crafting filter d: to ~32%"

Purpose of change

Describe the solution

Describe alternatives you've considered

Testing

I had it on for a while and noticed this makes a significant difference for d: filter, as shown by profiling:

image
Original code.

Note:

  1. Line 6102 Makes a copy, but get_group_available_recipes returns const reference. Takes 20.3 seconds
  2. Line 6121 Destroying the copies takes another 9.2 seconds.

image
Making it a reference - first commit.

Note:

  1. Times on 6102 and (now) 6122 are next to 0 ms, which is 30.4 seconds (or 50%) improvement.
  2. But line 6112 now takes 9500ms up from 8500ms.

image
Making cache - second commit.

Note:

  1. Line (now) 6130 takes only 900ms, which is 9 to 11 times improvement.
  2. This line is responsible for making and calling for the cache. Clearly, a single search asks for each can_make about 10 times.

Additional context

 - copying and destroying took 29 seconds for single crafting filter `f:` search. Now it is next to 0 ms
 - (`d:` filter now takes 50% of time)
 - Single search with filter `d:` now takes 900 ms insead of 9 500 ms asking for can_craft
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jan 4, 2025
@Brambor Brambor added the Info / User Interface Game - player communication, menus, etc. label Jan 4, 2025
src/item.cpp Show resolved Hide resolved
@Brambor Brambor closed this Jan 4, 2025
@Brambor Brambor reopened this Jan 4, 2025
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jan 4, 2025
@Brambor Brambor marked this pull request as draft January 4, 2025 23:13
@Brambor Brambor marked this pull request as ready for review January 4, 2025 23:14
@Maleclypse Maleclypse merged commit ef837bd into CleverRaven:master Jan 5, 2025
53 of 70 checks passed
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 5, 2025
@Brambor Brambor deleted the performance-item-info branch January 5, 2025 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) Info / User Interface Game - player communication, menus, etc. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants