Skip to content

perf(codegen): reduce memory usage in SourcemapBuilder#13679

Merged
graphite-app[bot] merged 1 commit intomainfrom
09-11-perf_codegen_reduce_memory_usage_in_sourcemapbuilder_
Sep 11, 2025
Merged

perf(codegen): reduce memory usage in SourcemapBuilder#13679
graphite-app[bot] merged 1 commit intomainfrom
09-11-perf_codegen_reduce_memory_usage_in_sourcemapbuilder_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Sep 11, 2025

#13670 optimized SourcemapBuilder to pre-reserve capacity in columns Vec.

However, after #13677, columns will resize adaptively depending on how many unicode chars in source text. So now initial capacity of 256 (1 KiB) is probably excessive for most cases. Reduce it to 16 (64 bytes, which is 1 x CPU cache line).

Codspeed shows little change in perf (max +0.1%, min -0.1%), and memory usage will definitely be reduced.

Copy link
Member Author

overlookmotel commented Sep 11, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-codegen Area - Code Generation C-performance Category - Solution not expected to change functional behavior, only performance labels Sep 11, 2025
@overlookmotel overlookmotel marked this pull request as ready for review September 11, 2025 07:16
@overlookmotel overlookmotel marked this pull request as draft September 11, 2025 07:16
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 11, 2025

CodSpeed Instrumentation Performance Report

Merging #13679 will not alter performance

Comparing 09-11-perf_codegen_reduce_memory_usage_in_sourcemapbuilder_ (d4608f1) with main (239d4cb)1

Summary

✅ 37 untouched benchmarks

Footnotes

  1. No successful run was found on main (4ded22b) during the generation of this report, so 239d4cb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review September 11, 2025 07:20
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Sep 11, 2025
Copy link
Member

Boshen commented Sep 11, 2025

Merge activity

#13670 optimized `SourcemapBuilder` to pre-reserve capacity in `columns` `Vec`.

However, after #13677, `columns` will resize adaptively depending on how many unicode chars in source text. So now initial capacity of 256 (1 KiB) is probably excessive for most cases. Reduce it to 16 (64 bytes, which is 1 x CPU cache line).

Codspeed shows little change in perf (max +0.1%, min -0.1%), and memory usage will definitely be reduced.
@graphite-app graphite-app bot force-pushed the 09-11-perf_codegen_reduce_allocations_in_sourcemapbuilder_ branch from 3613afd to 4ded22b Compare September 11, 2025 07:31
@graphite-app graphite-app bot force-pushed the 09-11-perf_codegen_reduce_memory_usage_in_sourcemapbuilder_ branch from 02da60b to d4608f1 Compare September 11, 2025 07:32
Base automatically changed from 09-11-perf_codegen_reduce_allocations_in_sourcemapbuilder_ to main September 11, 2025 07:36
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 11, 2025
@graphite-app graphite-app bot merged commit d4608f1 into main Sep 11, 2025
27 checks passed
@graphite-app graphite-app bot deleted the 09-11-perf_codegen_reduce_memory_usage_in_sourcemapbuilder_ branch September 11, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants