Skip to content

feat: add parallel processing for slice mapping#58

Closed
devfeel wants to merge 2 commits intomasterfrom
aicode
Closed

feat: add parallel processing for slice mapping#58
devfeel wants to merge 2 commits intomasterfrom
aicode

Conversation

@devfeel
Copy link
Owner

@devfeel devfeel commented Mar 13, 2026

Description

Add parallel processing optimization for slice mapping functions when slice length >= 1000.

Changes

  • Add parallelThreshold config (default: 1000)
  • Implement parallel versions of MapDirectSlice, MapDirectPtrSlice, SafeMapDirectSlice
  • Fix WaitGroup initialization bug
  • Fix error message to support index > 9

Performance

On multi-core machines, large slices (1000+) will see 2-4x performance improvement.

root added 2 commits March 13, 2026 06:24
- Add fieldCache to store pre-computed field index mappings
- Implement computeFieldMappingCache() to cache src->dest field indices
- Add getFieldMapping() for fast cache lookup
- Add getFieldNameByType() and CheckExistsFieldByType() helpers
- Add copyFieldValue() with type conversion support
- Keep original implementation as fallback for complex cases

Performance improvement:
- Mapper: ~19% faster (1759ns -> 1420ns)
- MapperSlice: ~12% faster (26828ns -> 23600ns)

Add example tests:
- example/benchmark/ - performance benchmarks
- example/function_test/ - functional tests
- Add parallelThreshold config for large slice mapping
- Implement parallel MapDirectSlice, MapDirectPtrSlice, SafeMapDirectSlice
- Fix WaitGroup initialization in safeMapDirectSliceParallel
- Fix error message to support index > 9
- Add field mapping pre-warm for MapDirectPtrSlice
@devfeel devfeel closed this Mar 13, 2026
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