Skip to content

Conversation

@Mosch0512
Copy link
Contributor

Tested in Devias 3 i had about 8+% fps increase.

There is definitely other checks that could get a similar update later

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.

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

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 introduces a robust caching mechanism for skill requirement checks, dramatically enhancing game performance by eliminating repetitive computations. By intelligently storing and invalidating these checks based on character state changes, the system provides a smoother and more responsive user experience, especially in scenarios where skill evaluations are frequent.

Highlights

  • Skill Requirements Caching: Implemented a caching layer for AreSkillRequirementsFulfilled to prevent redundant calculations and significantly improve performance when checking skill prerequisites.
  • Intelligent Cache Invalidation: The skill requirements cache is automatically invalidated when relevant character data changes, including level-ups, stat point allocations, skill changes (learning/unlearning), and equipment changes that recalculate stats.
  • Cache Initialization on Login: The skill requirements cache is initialized and rebuilt upon character login (joining a map server) to ensure accurate data is available from the start of a session.
  • Refactored Skill Check Logic: The detailed logic for determining if skill requirements are met has been extracted and moved into a new private method, RebuildSkillRequirementsCache, improving code organization and maintainability.

🧠 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
    • Initialized m_bSkillRequirementsCacheDirty and m_aSkillRequirementsFulfilled in the constructor.
    • Modified AreSkillRequirementsFulfilled to utilize the cache and trigger a rebuild if the cache is dirty.
    • Added InvalidateSkillRequirementsCache method to mark the cache as dirty.
    • Added InitializeSkillRequirementsCache method to force a cache rebuild, used upon character login.
    • Created RebuildSkillRequirementsCache method to encapsulate the logic for calculating and storing the fulfillment status for all skills.
  • src/source/SkillManager.h
    • Declared new public methods for cache management: InvalidateSkillRequirementsCache and InitializeSkillRequirementsCache.
    • Declared a new private method RebuildSkillRequirementsCache.
    • Added private member variables m_bSkillRequirementsCacheDirty (boolean flag) and m_aSkillRequirementsFulfilled (boolean array) to manage the cache state and storage.
  • src/source/WSclient.cpp
    • Added a call to gSkillManager.InitializeSkillRequirementsCache() within ReceiveJoinMapServer to ensure the cache is fresh when a character logs in.
    • Added a call to gSkillManager.InvalidateSkillRequirementsCache() within ReceiveMagicList when character skills are updated.
    • Added calls to gSkillManager.InvalidateSkillRequirementsCache() within ReceiveLevelUp when a character gains a level.
    • Added a call to gSkillManager.InvalidateSkillRequirementsCache() within ReceiveSetPointsExtended when character stats are updated.
  • src/source/ZzzInfomation.cpp
    • Added a call to gSkillManager.InvalidateSkillRequirementsCache() within CHARACTER_MACHINE::CalculateAll to ensure the cache is invalidated when character stats are recalculated (e.g., due to equipment changes).
Activity
  • No human activity (comments, reviews, approvals) has occurred on this pull request yet.
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
Contributor

@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 mechanism for skill requirement checks, which is a great performance improvement. The implementation is mostly correct, with cache invalidation points well-placed. I've found a few issues, including a potential critical bug in the cache rebuilding logic and some opportunities for code cleanup to improve maintainability. Please see my detailed comments.

Comment on lines +6560 to +6562
// Character stats changed, invalidate skill requirements cache
// it is called in `CalculatedAll` already, but for future changes and understandability also kept here because it does not have a huge impact.
gSkillManager.InvalidateSkillRequirementsCache();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment acknowledges that InvalidateSkillRequirementsCache() is already called within CharacterMachine->CalculateAll(). To avoid redundancy and improve code clarity, this duplicate call should be removed. Relying on CalculateAll() to handle the cache invalidation centralizes the logic and makes the code easier to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you say @sven-n

Copy link
Owner

Choose a reason for hiding this comment

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

It's okay

@sven-n
Copy link
Owner

sven-n commented Feb 4, 2026

Nice improvement :) Thank you!

@sven-n sven-n merged commit 8dc8312 into sven-n:main Feb 4, 2026
1 check 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.

2 participants