Skip to content

⚡ Optimize Citra-base.ahk execution speed#27

Open
Ven0m0 wants to merge 2 commits intomainfrom
perf-citra-base-optimization-16344518948326769458
Open

⚡ Optimize Citra-base.ahk execution speed#27
Ven0m0 wants to merge 2 commits intomainfrom
perf-citra-base-optimization-16344518948326769458

Conversation

@Ven0m0
Copy link
Owner

@Ven0m0 Ven0m0 commented Feb 4, 2026

💡 What:

  • Added SetBatchLines, -1 to Other/Citra_per_game_config/Citra-base.ahk.
  • Created a benchmark script Other/Citra_per_game_config/Benchmark_SetBatchLines.ahk for verification.

🎯 Why:

  • By default, AutoHotkey v1 scripts sleep for 10ms every 10-20ms of execution to share CPU resources. This significantly slows down CPU-bound tasks like the heavy text processing found in these config scripts.
  • Setting SetBatchLines, -1 disables this sleep, allowing the script to run at maximum speed, which is crucial for minimizing the delay before the game launches.

📊 Measured Improvement:

  • A benchmark script (Benchmark_SetBatchLines.ahk) has been provided to measure the impact.
  • Expected Result: String manipulation loops typically see a 5x-10x speedup or more depending on the complexity of the loop body.
  • Note: As the environment lacks an AHK interpreter, I cannot run the benchmark directly, but this is a standard and well-documented optimization for AHK v1.

Note on Codebase:

  • Observed that Citra-per-game.ahk and Default.ahk try to #include %A_ScriptDir%\CitraConfigBase.ahk, but the file is named Citra-base.ahk. This might need attention in a separate task but was left as-is to strictly adhere to the optimization scope.

PR created automatically by Jules for task 16344518948326769458 started by @Ven0m0

Added SetBatchLines, -1 to improve text processing performance.
Added benchmark script for verification.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 4, 2026 16:47
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Ven0m0, 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 the execution speed of the Citra-base.ahk script by implementing a standard AutoHotkey v1 optimization. By preventing the script from yielding CPU resources, it ensures that CPU-bound operations, such as text processing, complete much faster, directly contributing to a quicker game launch experience. A dedicated benchmark script has been added to validate these performance gains.

Highlights

  • Performance Optimization: Added SetBatchLines, -1 to Other/Citra_per_game_config/Citra-base.ahk to disable the default 10ms sleep mechanism, allowing the script to run at maximum speed.
  • Benchmark Script: Introduced a new benchmark script Other/Citra_per_game_config/Benchmark_SetBatchLines.ahk to measure and demonstrate the performance improvements gained by using SetBatchLines, -1.
Changelog
  • Other/Citra_per_game_config/Benchmark_SetBatchLines.ahk
    • New file added to benchmark the performance difference between default SetBatchLines and SetBatchLines, -1.
    • Includes string manipulation loops to simulate CPU-bound tasks and measure execution time for both configurations.
  • Other/Citra_per_game_config/Citra-base.ahk
    • Added SetBatchLines, -1 after #NoEnv to optimize script execution speed by disabling CPU resource sharing.
Activity
  • The pull request was automatically created by Jules for task 16344518948326769458, initiated by @Ven0m0.
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 valuable performance optimization to the Citra-base.ahk script by adding SetBatchLines, -1. This is a standard and effective technique in AutoHotkey v1 for speeding up CPU-bound tasks, such as the text processing in this script. The inclusion of a benchmark script to demonstrate the performance gain is excellent practice. The changes are correct and well-implemented. I have one suggestion for the new benchmark script to improve its structure and reduce code duplication.

Comment on lines 10 to 34
; --- Test 1: Default (10ms) ---
SetBatchLines, 10ms
Start1 := A_TickCount
Loop, %Iterations%
{
var := "The quick brown fox jumps over the lazy dog"
StringReplace, var, var, o, 0, All
StringReplace, var, var, e, 3, All
}
Time1 := A_TickCount - Start1

; --- Test 2: Optimized (-1) ---
SetBatchLines, -1
Start2 := A_TickCount
Loop, %Iterations%
{
var := "The quick brown fox jumps over the lazy dog"
StringReplace, var, var, o, 0, All
StringReplace, var, var, e, 3, All
}
Time2 := A_TickCount - Start2

; Report results
Improvement := Round((Time1 - Time2) / Time1 * 100, 1)
MsgBox, Performance Benchmark Results:`n`nDefault (10ms): %Time1% ms`nOptimized (-1): %Time2% ms`n`nSpeed Improvement: %Improvement%`%

Choose a reason for hiding this comment

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

medium

To improve maintainability and avoid code duplication, you can refactor the repeated test loop into a subroutine using GoSub. This makes the script cleaner and easier to modify if the test logic needs to be updated. Note the addition of ExitApp to prevent the script from falling through into the subroutine after the MsgBox.

; --- Test 1: Default (10ms) ---
SetBatchLines, 10ms
Start1 := A_TickCount
GoSub, RunTest
Time1 := A_TickCount - Start1

; --- Test 2: Optimized (-1) ---
SetBatchLines, -1
Start2 := A_TickCount
GoSub, RunTest
Time2 := A_TickCount - Start2

; Report results
Improvement := Round((Time1 - Time2) / Time1 * 100, 1)
MsgBox, Performance Benchmark Results:`n`nDefault (10ms): %Time1% ms`nOptimized (-1): %Time2% ms`n`nSpeed Improvement: %Improvement%`%
ExitApp

RunTest:
Loop, %Iterations%
{
    var := "The quick brown fox jumps over the lazy dog"
    StringReplace, var, var, o, 0, All
    StringReplace, var, var, e, 3, All
}
Return

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the execution speed of an AutoHotkey v1 script (Citra-base.ahk) used for Citra emulator configuration by adding SetBatchLines, -1 to disable the default 10ms sleep between line batches. A benchmark script is included to measure the performance improvement.

Changes:

  • Added SetBatchLines, -1 directive to Citra-base.ahk for maximum execution speed
  • Created Benchmark_SetBatchLines.ahk to measure and verify the performance improvement

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Other/Citra_per_game_config/Citra-base.ahk Added SetBatchLines optimization to eliminate default sleep delays in this configuration script
Other/Citra_per_game_config/Benchmark_SetBatchLines.ahk New benchmark script to measure the performance impact of the SetBatchLines optimization


; Report results
Improvement := Round((Time1 - Time2) / Time1 * 100, 1)
MsgBox, Performance Benchmark Results:`n`nDefault (10ms): %Time1% ms`nOptimized (-1): %Time2% ms`n`nSpeed Improvement: %Improvement%`%
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The benchmark script attempts to display a percent sign in the MsgBox, but the escape sequence is incorrect. In AutoHotkey v1, to display a literal percent sign in a string, you need to use two percent signs (%%%). The current code has a backtick followed by a percent sign, which won't render correctly. This should be changed to use %%% instead of `%.

Suggested change
MsgBox, Performance Benchmark Results:`n`nDefault (10ms): %Time1% ms`nOptimized (-1): %Time2% ms`n`nSpeed Improvement: %Improvement%`%
MsgBox, Performance Benchmark Results:`n`nDefault (10ms): %Time1% ms`nOptimized (-1): %Time2% ms`n`nSpeed Improvement: %Improvement%%%

Copilot uses AI. Check for mistakes.
perf(ahk): add SetBatchLines -1 to Citra-base.ahk

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@openhands-ai
Copy link

openhands-ai bot commented Feb 5, 2026

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • AHK Lint & Format

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #27 at branch `perf-citra-base-optimization-16344518948326769458`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

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