Skip to content

feat: Optimizations for itinerary locality and SmallVec for active settings#90

Merged
RobertJacobsonCDC merged 1 commit intomainfrom
RobertJacobsonCDC_itinerary_locality
May 7, 2026
Merged

feat: Optimizations for itinerary locality and SmallVec for active settings#90
RobertJacobsonCDC merged 1 commit intomainfrom
RobertJacobsonCDC_itinerary_locality

Conversation

@RobertJacobsonCDC
Copy link
Copy Markdown
Collaborator

@RobertJacobsonCDC RobertJacobsonCDC commented Apr 9, 2026

This PR is stacked on top of #89. It introduces two optimizations:

  1. It stores a person's SettingIds and ItineraryRatios in a single property instead of in two separate properties. These are often fetched together. This improves data locality.
  2. It uses SmallVec for get_active_settings_for_person, avoiding allocating a vector on the heap for this common operation.

Local benchmark results

======================================================================
  RobertJacobsonCDC_setting_code_value (e364888) vs RobertJacobsonCDC_itinerary_locality
======================================================================

  Benchmark                                      Base         Current  Change
  ---                                             ---             ---  ---
  init/population/10k                       3.3204 ms       2.9560 ms  -11.0% faster ✓
  init/population/100k                      40.452 ms       37.420 ms  -7.5% faster ✓
  execute/population/10k                    71.617 ms       70.163 ms  -2.0% faster ✓
  execute/population/100k                    1.2048 s        1.1222 s  -6.9% faster ✓

======================================================================

Keep in mind this is comparing against RobertJacobsonCDC_setting_code_value, not the current main branch. Here's a comparison to the current main:

======================================================================
  main (9132b89) vs RobertJacobsonCDC_itinerary_locality
======================================================================

  Benchmark                                      Base         Current  Change
  ---                                             ---             ---  ---
  init/population/10k                       10.994 ms       2.8994 ms  -73.6% faster ✓
  init/population/100k                      113.70 ms       38.173 ms  -66.4% faster ✓
  execute/population/10k                    76.380 ms       70.111 ms  -8.2% faster ✓
  execute/population/100k                    1.1755 s        1.1251 s  -4.3% faster ✓

======================================================================

@RobertJacobsonCDC RobertJacobsonCDC force-pushed the RobertJacobsonCDC_setting_code_value branch from e364888 to ba2c81d Compare April 10, 2026 21:53
@RobertJacobsonCDC RobertJacobsonCDC changed the base branch from RobertJacobsonCDC_setting_code_value to main April 17, 2026 03:57
@RobertJacobsonCDC RobertJacobsonCDC marked this pull request as ready for review April 17, 2026 03:57
@RobertJacobsonCDC RobertJacobsonCDC force-pushed the RobertJacobsonCDC_itinerary_locality branch from 5a01b62 to 3417511 Compare April 17, 2026 04:56
@RobertJacobsonCDC RobertJacobsonCDC force-pushed the RobertJacobsonCDC_itinerary_locality branch from 3417511 to 7e32a23 Compare May 5, 2026 15:28
Copy link
Copy Markdown
Collaborator

@erik-rosenstrom erik-rosenstrom left a comment

Choose a reason for hiding this comment

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

Looking good to me!

@RobertJacobsonCDC RobertJacobsonCDC merged commit 4a4bb7b into main May 7, 2026
4 checks passed
@RobertJacobsonCDC RobertJacobsonCDC deleted the RobertJacobsonCDC_itinerary_locality branch May 7, 2026 16:06
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