Skip to content

Reorder win-checks to improve performance #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2025

Conversation

yy214123
Copy link
Contributor

Reorder win-check logic to favor row-wise over column-wise checks. This aligns better with C’s row-major memory layout, enhancing spatial locality. It reduces cache line crossings, cuts down total instruction count, and improves sequential memory access— especially useful for large boards or frequent evaluations.

Benchmark on a 5×5 board (1M iterations):

  • Instructions: 20,042,179,354 → 9,528,171,690 (-52.5%)
  • Cache refs: 205,075 → 115,548 (-43.65%)
  • Cache misses: 28,503 → 20,176 (-29.23%)
  • Time elapsed: 0.971s → 0.597s (-38.5%)

Despite a minor rise in miss rate, total misses declined due to fewer cache references.

Reorder win-check logic to favor row-wise over column-wise checks.
This aligns better with C’s row-major memory layout, enhancing
spatial locality. It reduces cache line crossings, cuts down
total instruction count, and improves sequential memory access—
especially useful for large boards or frequent evaluations.

Benchmark on a 5×5 board (1M iterations):

- Instructions: 20,042,179,354 → 9,528,171,690   (-52.5%)
- Cache refs:         205,075 →        115,548   (-43.65%)
- Cache misses:        28,503 →         20,176   (-29.23%)
- Time elapsed:        0.971s →         0.597s   (-38.5%)

Despite a minor rise in miss rate, total misses declined due to fewer
cache references.
@jserv jserv merged commit efff9ee into sysprog21:main Apr 21, 2025
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