Skip to content

Implement skill requirements caching: Introduce caching system for sk…#26

Merged
Mosch0512 merged 5 commits intomainfrom
improve-performance-skill-req-check-caching
Feb 4, 2026
Merged

Implement skill requirements caching: Introduce caching system for sk…#26
Mosch0512 merged 5 commits intomainfrom
improve-performance-skill-req-check-caching

Conversation

@Mosch0512
Copy link
Owner

…ill requirement checks to optimize performance. Add invalidation on relevant stat, item, and skill changes, and initialize cache on character login.

…ill requirement checks to optimize performance. Add invalidation on relevant stat, item, and skill changes, and initialize cache on character login.
@gemini-code-assist
Copy link

Summary of Changes

Hello @Mosch0512, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances performance by implementing a caching layer for skill requirement checks. Instead of recalculating skill prerequisites every time, the system now stores these results and intelligently invalidates the cache only when underlying character attributes, skills, or equipment change. This approach minimizes computational overhead, leading to a smoother and more responsive user experience, especially in scenarios where skill checks are frequent.

Highlights

  • Skill Requirements Caching: Introduced a caching system for AreSkillRequirementsFulfilled to optimize performance by avoiding redundant calculations of skill requirements.
  • Cache Invalidation: Implemented mechanisms to invalidate the skill requirements cache when relevant character data changes, including character level-ups, stat point allocations, skill changes (learning/unlearning), and equipment changes that recalculate stats.
  • Cache Initialization: Ensured the skill requirements cache is initialized and rebuilt upon character login (joining a map server) to provide accurate data from the start of a session.
  • Refactored Skill Check Logic: The detailed logic for checking individual skill requirements has been moved into a new private RebuildSkillRequirementsCache method, which populates the cache for all skills.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/source/SkillManager.cpp
    • Added m_bSkillRequirementsCacheDirty flag and m_aSkillRequirementsFulfilled array to the CSkillManager class.
    • Modified the CSkillManager constructor to initialize the cache dirty flag and clear the cache array.
    • Refactored AreSkillRequirementsFulfilled to check the cache dirty flag and rebuild the cache if necessary, then return the cached result.
    • Implemented new public methods InvalidateSkillRequirementsCache and InitializeSkillRequirementsCache.
    • Implemented a new private method RebuildSkillRequirementsCache which contains the original skill requirement calculation logic and populates the cache array for all skills.
  • src/source/SkillManager.h
    • Declared new public methods InvalidateSkillRequirementsCache and InitializeSkillRequirementsCache.
    • Declared a new private method RebuildSkillRequirementsCache.
    • Added private member variables m_bSkillRequirementsCacheDirty (boolean) and m_aSkillRequirementsFulfilled (boolean array) to CSkillManager.
  • src/source/WSclient.cpp
    • Added a call to gSkillManager.InitializeSkillRequirementsCache() within ReceiveJoinMapServer to initialize the cache on character login.
    • Added a call to gSkillManager.InvalidateSkillRequirementsCache() within ReceiveMagicList to invalidate the cache when skills change.
    • Added calls to gSkillManager.InvalidateSkillRequirementsCache() within ReceiveLevelUp (two locations) to invalidate the cache when character level changes.
    • Added a call to gSkillManager.InvalidateSkillRequirementsCache() within ReceiveSetPointsExtended to invalidate the cache when character stats are updated.
  • src/source/ZzzInfomation.cpp
    • Added a call to gSkillManager.InvalidateSkillRequirementsCache() within CHARACTER_MACHINE::CalculateAll() to invalidate the cache when character stats are recalculated (e.g., due to equipment changes).
Activity
  • The pull request was created by Mosch0512 with the intent to implement a caching system for skill requirement checks to optimize performance.
  • The initial description outlines the addition of cache invalidation on relevant stat, item, and skill changes, and cache initialization on character login.
  • No further review comments or activity have been recorded in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a caching system for skill requirement checks, which is a great initiative for performance optimization. The implementation correctly identifies most of the places where the cache needs to be invalidated.

I've made a couple of suggestions:

  • One to optimize the cache rebuilding logic by hoisting loop-invariant computations.
  • Another to remove a redundant cache invalidation call.

Overall, this is a solid improvement.

Comment on lines 6559 to 6561

// Character stats changed, invalidate skill requirements cache
gSkillManager.InvalidateSkillRequirementsCache();

Choose a reason for hiding this comment

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

medium

The call to gSkillManager.InvalidateSkillRequirementsCache() here is redundant. The preceding call to CharacterMachine->CalculateAll() already invalidates the skill requirements cache in ZzzInfomation.cpp.

Removing this redundant call will make the code cleaner and avoid unnecessary function calls.

@Mosch0512 Mosch0512 merged commit 8dc8312 into main Feb 4, 2026
2 checks passed
@Mosch0512 Mosch0512 deleted the improve-performance-skill-req-check-caching branch February 4, 2026 19:01
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.

1 participant