Skip to content

Cache range and position#940

Merged
markwpearce merged 1 commit into
release-0.66.0from
cache-range-and-position
Nov 9, 2023
Merged

Cache range and position#940
markwpearce merged 1 commit into
release-0.66.0from
cache-range-and-position

Conversation

@TwitchBronBron

@TwitchBronBron TwitchBronBron commented Nov 3, 2023

Copy link
Copy Markdown
Member

Cache the range and position objects since they're immutable. This helps reduce memory footprint and garbage collection churn. Also after a range has been created at least once, it should theoretically cost less CPU cycles since we just look it up from the cache instead of building a new one.

For a large private project:

location cache: DISABLED 
build: (8s191.958ms) (7s967.413ms) (8s222.454ms) (8s035.043ms) | (avg: 8.104217seconds)
watch: (8s103.313ms) (8s104.476ms) (8s200.875ms) (8s100.466ms) | (avg: 8.127283seconds)

location cache: ENABLED
build:  (7s965.510ms) (7s977.796ms) (8s167.780ms) (7s960.608ms) (avg: 7.7679235seconds)
watch:  (7s873.529ms) (7s967.520ms) (8s018.557ms) (8s091.832ms) (avg: 7.9878595seconds)

For the same project, we end up caching a ton of ranges and positions. As the app lives in watch mode for a while, I would expect more and more of those locations to get recycled:

cold boot:
Ranges:    254,551 cached 193,085 not cached
Positions: 418,227 cached   10,588 not cached

after 4 watch validations:
Ranges:    392,111 cached 163,335 not cached
Positions: 418,227 cached  10,588 not cached

@markwpearce
markwpearce merged commit c22940e into release-0.66.0 Nov 9, 2023
@markwpearce
markwpearce deleted the cache-range-and-position branch November 9, 2023 17:11
@TwitchBronBron TwitchBronBron added this to the v1.0.0 milestone Jan 24, 2024
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