Skip to content
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

perf: Slightly optimise object interner for larger codebase #5170

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

Conversation

siketyan
Copy link

We have a larger codebase of TypeSpec (total. 17K lines formatted) and found that emitting part is very slow than the compile part, taking 15 seconds avg. on my M3 Pro machine.

After enabling --cpu-prof option of Node.js, I found that intern function is taking larger part of the framegraph. As the JSDoc says, it's not well optimised yet.

This pull request is maybe the first try of the optimisation and slightly improves the execution time of the emitting part. It lowed the execution time from 15 seconds to 6 seconds.

Profiling comparison

← after, before →

image

@bterlson
Copy link
Member

bterlson commented Nov 26, 2024

Hey cool, the bottleneck got hit 😁 How hard was the facepalm when you saw the comment?

This is a good simple approach. There are likely more optimal approaches that would be more work (e.g. I had considered sorting keys and then storing the known keys and values in a trie, which I think is effectively what the records and tuples polyfill does). But I don't think this can hurt to improve for now since it seems to help your perf significantly. Let's see what Will thinks.

@markcowl markcowl assigned markcowl and unassigned markcowl Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants