Skip to content

perf: optimize MappedCrossoverInsertMutator::mutate to eliminate redu…#3742

Open
ayush78490 wants to merge 1 commit intoAFLplusplus:mainfrom
ayush78490:optimize/mapped-crossover-redundancy
Open

perf: optimize MappedCrossoverInsertMutator::mutate to eliminate redu…#3742
ayush78490 wants to merge 1 commit intoAFLplusplus:mainfrom
ayush78490:optimize/mapped-crossover-redundancy

Conversation

@ayush78490
Copy link

@ayush78490 ayush78490 commented Feb 27, 2026

This commit addresses issue #3731 by consolidating redundant input loading and mapping operations in MappedCrossoverInsertMutator::mutate.

Previously, the function was:

  1. Loading and mapping the corpus input in a first borrow scope to calculate size
  2. Getting the same testcase again and loading/mapping it again in a second scope

This resulted in:

  • 2x get_from_all() calls
  • 2x load_input() calls
  • 2x input_mapper() invocations
  • Unnecessary borrow complexity
  • Reduced code readability

CHANGES:

  • Consolidate input loading and mapping into a single scope
  • Clone the mapped result to allow early borrow release
  • Drop testcase borrow before state mutations
  • Use match statement for cleaner error handling

PERFORMANCE IMPACT:

  • 50% reduction in redundant corpus accesses
  • 50% reduction in load operations
  • 50% reduction in mapper invocations
  • Improved code clarity and maintainability

TESTING:
All 7 mutation-related tests pass

Fixes #3731

Description

describe your PR here

Checklist

  • I have run ./scripts/precommit.sh and addressed all comments

…ndant operations

This commit addresses issue AFLplusplus#3731 by consolidating redundant input loading and
mapping operations in MappedCrossoverInsertMutator::mutate.

Previously, the function was:
1. Loading and mapping the corpus input in a first borrow scope to calculate size
2. Getting the same testcase again and loading/mapping it again in a second scope

This resulted in:
- 2x get_from_all() calls
- 2x load_input() calls
- 2x input_mapper() invocations
- Unnecessary borrow complexity
- Reduced code readability

CHANGES:
- Consolidate input loading and mapping into a single scope
- Clone the mapped result to allow early borrow release
- Drop testcase borrow before state mutations
- Use match statement for cleaner error handling

PERFORMANCE IMPACT:
- 50% reduction in redundant corpus accesses
- 50% reduction in load operations
- 50% reduction in mapper invocations
- Improved code clarity and maintainability

TESTING:
All 7 mutation-related tests pass

Fixes AFLplusplus#3731
@ayush78490 ayush78490 force-pushed the optimize/mapped-crossover-redundancy branch from c0265cc to 6b70183 Compare February 27, 2026 14:57
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.

Redundant Borrowing and Double Mapping in MappedCrossoverInsertMutator::mutate

1 participant