Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Optimize format of type list id strings used in maps#10240

Merged
ahejlsberg merged 1 commit into
mastermicrosoft/TypeScript:masterfrom
optimizeTypeListIdsmicrosoft/TypeScript:optimizeTypeListIdsCopy head branch name to clipboard
Aug 11, 2016
Merged

Optimize format of type list id strings used in maps#10240
ahejlsberg merged 1 commit into
mastermicrosoft/TypeScript:masterfrom
optimizeTypeListIdsmicrosoft/TypeScript:optimizeTypeListIdsCopy head branch name to clipboard

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

The compiler extensively uses caches to share instantiations of generic types as well as union, intersection, and tuple types. These caches are simply objects where the entries are keyed by property names synthesized from the unique IDs assigned to type objects. Previously we'd construct type cache keys as comma separated lists of type IDs. For example, the union type A | B | C | D would have a key like "1000,1001,1002,1003", where each numeric string is the unique ID of the type. This PR optimizes the key format by encoding two or more consecutive IDs as "xxxx:nnnn", where xxxx is the starting ID and nnnn is the number of IDs. So, the key for A | B | C | D simply becomes "1000:4" if the types have consecutive IDs. Since union types often have constituents with consecutive IDs (particularly union enum types), this can dramatically reduce the length of keys, which helps performance and memory consumption. Informal tests show a 2-3% speedup of the type check phase when compiling the compiler itself.

@weswigham

Copy link
Copy Markdown
Member

Almost a kind of run length encoding for IDs. Neat.

@ahejlsberg ahejlsberg merged commit e00ce94 into master Aug 11, 2016
@ahejlsberg ahejlsberg deleted the optimizeTypeListIds branch August 11, 2016 17:11
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.