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
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-18 - Unintended file modifications from tests
**Learning:** Running `uv run pytest` or targeted tests and scripts locally can regenerate files in the `results/` directory, causing unintended modifications to tracked benchmark baselines and snapshots.
**Action:** Always check `git status` after running tests/benchmarks and run `git restore --staged results/` and `git checkout results/` to clean up the repository before committing and submitting PRs.
Comment on lines +1 to +3

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

This new .jules note seems process-/tooling-related and not directly tied to the HullKVCache performance change described in the PR. If it’s intended to be checked in, please update the PR description to include it; otherwise consider dropping it from this PR to avoid unrelated diffs.

Copilot uses AI. Check for mistakes.
11 changes: 6 additions & 5 deletions src/geometry/hull_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
HardmaxResult,
NumberLike,
ValueLike,
_as_fraction,
_coerce_key,
_coerce_value,
_normalize_number,
Expand Down Expand Up @@ -205,10 +204,12 @@ def _rebuild_if_needed(self) -> None:
total_value_sum = [Fraction(0) for _ in range(self._value_width or 0)]

for index, (key, value) in enumerate(self._entries):
bucket = aggregates.setdefault(
key,
{"value_sum": [Fraction(0) for _ in value], "count": 0, "entry_indices": []},
)
# ⚑ Bolt Optimization: Avoid expensive eager evaluation of setdefault arguments
# Creating [Fraction(0) for _ in value] on every iteration is costly
Comment on lines +207 to +208

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

The inline comments reference a PR-/tool-specific label ("Bolt") and include a non-ASCII emoji. To keep long-term maintainability and avoid churn in source history, consider rephrasing this as a concise, generic performance comment (or removing it if the code is self-explanatory).

Suggested change
# ⚑ Bolt Optimization: Avoid expensive eager evaluation of setdefault arguments
# Creating [Fraction(0) for _ in value] on every iteration is costly
# Avoid allocating the default value_sum list for keys already present.

Copilot uses AI. Check for mistakes.
if key not in aggregates:
aggregates[key] = {"value_sum": [Fraction(0) for _ in value], "count": 0, "entry_indices": []}
bucket = aggregates[key]
Comment on lines +209 to +211

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

The new hot-loop pattern does two dict lookups for existing keys (if key not in aggregates then aggregates[key]). Since this change is specifically for performance, consider using a single-lookup pattern (e.g., bucket = aggregates.get(key) / try: ... except KeyError:) to avoid the extra lookup when keys repeat heavily.

Suggested change
if key not in aggregates:
aggregates[key] = {"value_sum": [Fraction(0) for _ in value], "count": 0, "entry_indices": []}
bucket = aggregates[key]
bucket = aggregates.get(key)
if bucket is None:
bucket = {"value_sum": [Fraction(0) for _ in value], "count": 0, "entry_indices": []}
aggregates[key] = bucket

Copilot uses AI. Check for mistakes.

for coord_index, coord in enumerate(value):
bucket["value_sum"][coord_index] += coord
total_value_sum[coord_index] += coord
Expand Down
1 change: 0 additions & 1 deletion src/model/free_running_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def _execute_instruction(
branch_taken: bool | None = None
memory_read: tuple[int, int] | None = None
memory_write: tuple[int, int] | None = None
halted = False

match instruction:
case Opcode.PUSH_CONST:
Expand Down
2 changes: 1 addition & 1 deletion src/model/r45_dual_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass

from bytecode import BoundedMemoryVMCase, lower_program, r43_bounded_memory_vm_cases
from bytecode import lower_program, r43_bounded_memory_vm_cases
from exec_trace import Program, TraceInterpreter
Comment on lines +5 to 6

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

This import cleanup appears unrelated to the PR title/description (which only mentions the HullKVCache setdefault optimization). Consider either updating the PR description to mention these extra changes or splitting the cleanup into a separate PR to keep scope focused.

Copilot uses AI. Check for mistakes.

from .exact_hardmax import extract_stack_slot_operations
Expand Down