Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Other/Citra_mods/Citra_3DS_Manager.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#SingleInstance Force
#Warn
#NoEnv
SetBatchLines, -1

Choose a reason for hiding this comment

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

medium

This is a great performance optimization. To improve code clarity and maintainability, it would be beneficial to add a comment explaining the purpose of SetBatchLines, -1. This helps future developers understand this non-obvious performance tweak without needing to look up the documentation.

For example:

; Run script at maximum speed. This removes the default artificial delay,
; significantly improving performance for CPU-bound tasks like loops and string processing.
SetBatchLines, -1

Comment on lines 1 to +4
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.

This script uses AutoHotkey v1 syntax, which violates the repository's coding guidelines that mandate targeting AutoHotkey v2.x syntax exclusively. The repository contains v2 versions of similar Citra scripts (see Other/Citra_per_game_config/v2/), establishing a clear pattern for migration. Consider migrating this script to v2 syntax, which would include:

  • Adding #Requires AutoHotkey v2.0 directive
  • Using SetBatchLines(-1) function syntax instead of SetBatchLines, -1 command syntax
  • Converting other v1 commands to v2 function syntax (e.g., Loop Read to Loop Read(), FileExist to FileExist())
  • Updating variable references from %var% to expression syntax

Reference: Repository guideline 1000002 explicitly requires v2 syntax.

Copilot generated this review using guidance from repository custom instructions.
SetWorkingDir %A_ScriptDir%
ListLines Off
DetectHiddenWindows, Off
Expand Down
12 changes: 12 additions & 0 deletions Other/Citra_mods/PERFORMANCE_RATIONALE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Performance Optimization: Disable Batch Lines

**Change:** Added `SetBatchLines, -1` to the auto-execute section of `Citra_3DS_Manager.ahk`.

**Why:** By default, AutoHotkey scripts sleep for 10ms after every 10ms of execution to avoid monopolizing the CPU. This behavior, while friendly to single-core systems of the past, introduces significant latency in loops and string processing tasks.
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 description of SetBatchLines behavior is technically inaccurate. AutoHotkey v1 doesn't "sleep for 10ms after every 10ms of execution" - it sleeps for 10ms after every 10 lines of execution (by default). The default value is SetBatchLines, 20, meaning the script pauses for 10ms after every 20 lines executed, not based on time elapsed. This is an important distinction as it clarifies why -1 (never pause) provides the performance benefit.

Suggested change
**Why:** By default, AutoHotkey scripts sleep for 10ms after every 10ms of execution to avoid monopolizing the CPU. This behavior, while friendly to single-core systems of the past, introduces significant latency in loops and string processing tasks.
**Why:** By default, AutoHotkey v1 uses `SetBatchLines, 20`, which makes the script sleep for 10ms after every 20 lines of execution to avoid monopolizing the CPU. This behavior, while friendly to single-core systems of the past, introduces significant latency in loops and string processing tasks.

Copilot uses AI. Check for mistakes.

**Impact:** `SetBatchLines, -1` disables this sleep behavior, allowing the script to run as fast as possible. This is particularly effective for:
- `Loop, Read` (file reading)
- `Loop, Files` (file scanning)
- String manipulation (RegEx, parsing)

**Measurement Note:** Due to the current Linux environment lacking a Windows execution compatibility layer (Wine) for AutoHotkey, a direct runtime benchmark could not be performed. However, this is a standard and well-documented optimization for AHK v1 scripts, with expected speedups of 100% or more in tight loops.
Comment on lines +1 to +12

Choose a reason for hiding this comment

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

medium

While the explanation here is excellent, adding a separate documentation file for a single-line optimization can add clutter to the project's file structure. This kind of specific, localized documentation is often more effective and maintainable as a code comment directly next to the line it describes (as suggested for Citra_3DS_Manager.ahk). The git commit history also serves as a record for the 'why'. Consider removing this file and incorporating a summary into a code comment to keep the repository clean.

Comment on lines +3 to +12
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 statement "By default, AutoHotkey v1 scripts sleep for 10ms every 10ms of execution" is technically inaccurate. The default behavior is SetBatchLines, 20 (not 10), which means the script pauses for 10ms after every 20 lines executed, not based on elapsed time. Also, in AutoHotkey v2 (which this repository's guidelines mandate), SetBatchLines has been removed entirely - scripts run at full speed by default, making this optimization unnecessary in v2.

Suggested change
**Change:** Added `SetBatchLines, -1` to the auto-execute section of `Citra_3DS_Manager.ahk`.
**Why:** By default, AutoHotkey scripts sleep for 10ms after every 10ms of execution to avoid monopolizing the CPU. This behavior, while friendly to single-core systems of the past, introduces significant latency in loops and string processing tasks.
**Impact:** `SetBatchLines, -1` disables this sleep behavior, allowing the script to run as fast as possible. This is particularly effective for:
- `Loop, Read` (file reading)
- `Loop, Files` (file scanning)
- String manipulation (RegEx, parsing)
**Measurement Note:** Due to the current Linux environment lacking a Windows execution compatibility layer (Wine) for AutoHotkey, a direct runtime benchmark could not be performed. However, this is a standard and well-documented optimization for AHK v1 scripts, with expected speedups of 100% or more in tight loops.
**Change (legacy AHK v1 script):** Added `SetBatchLines, -1` to the auto-execute section of `Citra_3DS_Manager.ahk`.
**Why:** In AutoHotkey v1, the default setting is `SetBatchLines, 20`, which makes the script pause for 10ms after every 20 lines of code are executed to avoid monopolizing the CPU. This behavior, while friendly to single-core systems of the past, introduces significant latency in tight loops and string processing tasks.
**Impact (AHK v1):** `SetBatchLines, -1` disables this pause behavior in v1, allowing the script to run as fast as possible. This is particularly effective for:
- `Loop, Read` (file reading)
- `Loop, Files` (file scanning)
- String manipulation (RegEx, parsing)
**AHK v2 Note:** AutoHotkey v2 removed `SetBatchLines`; scripts already run at full speed by default. This optimization is therefore only relevant for legacy v1 versions of the script and should not be added to v2 code.
**Measurement Note:** Due to the current Linux environment lacking a Windows execution compatibility layer (Wine) for AutoHotkey, a direct runtime benchmark of the v1 behavior could not be performed. However, this is a standard and well-documented optimization for AHK v1 scripts, with expected speedups of 100% or more in tight loops.

Copilot uses AI. Check for mistakes.
Loading