Skip to content

Conversation

@mountainMath
Copy link
Owner

Incorporate changes from #216 and resolve merge conflicts with main and bump version number to schedule for next release

dshkol and others added 13 commits November 11, 2025 21:31
Performance improvements:
- Replace repeated rbind() in loops with list accumulation + bind_rows()
- Cache full vector list once instead of repeated list_census_vectors() calls
- Affects parent_census_vectors() and child_census_vectors()

Changes:
- Add testthat and microbenchmark to Suggests in DESCRIPTION
- Optimize parent_census_vectors() and child_census_vectors() in R/census_vectors.R
- Add comprehensive unit tests in tests/testthat/test-census_vectors.R
- Add benchmark script in benchmarks/benchmark_rbind_loops.R

Expected performance gains: 10-100x for deep hierarchies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Created three benchmark scripts:
- benchmark_rbind_loops.R: Basic benchmark comparing old vs new rbind approach
- benchmark_realistic.R: Realistic hierarchy test (87K vectors, 8 levels)
- benchmark_cache_improvement.R: Demonstrates the key optimization

Key findings:
- parent_census_vectors: 1.92x faster (cache optimization)
- child_census_vectors: 1.23x faster (cache optimization)
- Caching full vector list once eliminates repeated I/O and deserialization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Performance improvements:
- Replace nested lapply/sapply with pre-allocated vectors
- Add early returns for edge cases (empty, single word, short text)
- Use simple for loop with vectorized paste operations

Changes:
- Optimize n-gram generation in semantic_search() (R/vector_discovery.R)
- Add 17 comprehensive unit tests (tests/testthat/test-semantic_search.R)
- Add benchmark script (benchmarks/benchmark_semantic_search.R)

Performance gains: 1.4x faster (30-40% speedup)
- 100 vectors: 1.37x speedup
- 500 vectors: 1.42x speedup
- 1000 vectors: 1.43x speedup

All tests passing (43 total)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- PERFORMANCE_SUMMARY.md: Comprehensive technical summary of all optimizations
- NEWS.md: User-facing changelog for v0.5.8 with performance improvements
- Documents 1.2-1.9x speedups in key functions
- Details testing infrastructure (43 unit tests)
- Provides benchmark reproduction instructions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Detailed performance improvement documentation
- Backward compatibility guarantees
- Trade-off analysis (memory vs speed)
- Reverse dependency impact assessment
- Testing and benchmarking details
- Migration path (no action required for users)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Complete overview document covering:
- Performance gains summary (1.2-1.9x speedups)
- Testing and quality assurance (43 tests)
- Trade-offs and risk analysis (LOW risk)
- Impact on users and maintainers
- Recommendations and next steps

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Merge branch 'main' into v0.5.11

# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	README.md
#	cran-comments.md
#	docs/404.html
#	docs/LICENSE-text.html
#	docs/articles/Dwellings_by_document_type_cross_tabulation.html
#	docs/articles/Making_maps_with_cancensus.html
#	docs/articles/Taxfiler_Data.html
#	docs/articles/cancensus.html
#	docs/articles/data_discovery.html
#	docs/articles/index.html
#	docs/articles/intersecting_geometries.html
#	docs/articles/statcan_attribute_files.html
#	docs/articles/statcan_wds.html
#	docs/authors.html
#	docs/index.html
#	docs/news/index.html
#	docs/pkgdown.yml
#	docs/reference/CODES_TABLE.html
#	docs/reference/COV_SKYTRAIN_STATIONS.html
#	docs/reference/add_unique_names_to_region_list.html
#	docs/reference/as_census_region_list.html
#	docs/reference/census_vectors.html
#	docs/reference/child_census_vectors.html
#	docs/reference/dataset_attribution.html
#	docs/reference/explore_census_regions.html
#	docs/reference/explore_census_vectors.html
#	docs/reference/find_census_vectors.html
#	docs/reference/get_census.html
#	docs/reference/get_census_geometry.html
#	docs/reference/get_intersecting_geometries.html
#	docs/reference/get_recalled_database.html
#	docs/reference/get_statcan_geo_suite.html
#	docs/reference/get_statcan_geographic_attributes.html
#	docs/reference/get_statcan_geographies.html
#	docs/reference/get_statcan_geography_relationships.html
#	docs/reference/get_statcan_wds_data.html
#	docs/reference/get_statcan_wds_metadata.html
#	docs/reference/index.html
#	docs/reference/label_vectors.html
#	docs/reference/list_cancensus_cache.html
#	docs/reference/list_census_datasets.html
#	docs/reference/list_census_regions.html
#	docs/reference/list_census_vectors.html
#	docs/reference/list_recalled_cached_data.html
#	docs/reference/parent_census_vectors.html
#	docs/reference/remove_from_cancensus_cache.html
#	docs/reference/remove_recalled_cached_data.html
#	docs/reference/search_census_regions.html
#	docs/reference/search_census_vectors.html
#	docs/reference/set_cancensus_api_key.html
#	docs/reference/set_cancensus_cache_path.html
#	docs/reference/show_cancensus_api_key.html
#	docs/reference/show_cancensus_cache_path.html
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.

3 participants