Skip to content

Fix performance bottleneck with scaling defines#128

Open
yousifBilal wants to merge 1 commit into
dalance:masterfrom
yousifBilal:fix-preprocessor-performance-problems
Open

Fix performance bottleneck with scaling defines#128
yousifBilal wants to merge 1 commit into
dalance:masterfrom
yousifBilal:fix-preprocessor-performance-problems

Conversation

@yousifBilal

@yousifBilal yousifBilal commented Jul 3, 2026

Copy link
Copy Markdown

I encountered a problem where I had a file with a lot of macro definitions (~ 1 million). The preprocessor just get stuck. With this change we get better results:

Pre change

number of definitions time
1k 0.11s
10k 3.15s
100k 298.71s
1m ?

Post change

number of definitions time
1k 0.1s
10k 0.32s
100k 2.87s
1m 28.62s

One change is regarding the skip_nodes. It was growing with each. Even though we never need the nodes that we exited from again. Also, the push to the skip nodes will just return once it found the Locate

The other change is to avoid copying the list of defines when we need to expand macros recursively, rather, we pass in a mutable reference to the defines map.

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