Skip to content

KCL: Preallocate space for all the paths #7843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamchalmers
Copy link
Contributor

@adamchalmers adamchalmers commented Jul 18, 2025

If you sketch a 100-sided shape, Rust will append 100 path segments to the underlying sketch. Unfortunately because the vector which stores the paths starts at capacity 0, this could cause quite a lot of allocations.

As an optimization, we will instead preallocate space for N paths, where N is the number of steps in the |> pipeline. This will hopefully reduce allocations.

This improves performance on mock_execute_mike_stress_test 5% on my Macbook (M2 Pro) but regresses it 14% on Codspeed. I don't know why there's such a big difference.

If you sketch a 100-sided shape, Rust will append 100 path segments to the underlying sketch.
Unfortunately because the vector which stores the paths starts at capacity 0, this could
cause quite a lot of allocations.

As an optimization, we will instead preallocate space for N paths, where N is the number
of steps in the |> pipeline. This will hopefully reduce allocations.
Copy link

vercel bot commented Jul 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2025 8:13pm

Copy link

codspeed-hq bot commented Jul 18, 2025

CodSpeed Instrumentation Performance Report

Merging #7843 will degrade performances by 13.53%

Comparing achalmers/mockexec (2ad3436) with main (399dbaf)1

Summary

❌ 1 regressions
✅ 88 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
mock_execute_mike_stress_test_program 289.5 ms 334.7 ms -13.53%

Footnotes

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

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