Skip to content

Limit scope Validation#1586

Merged
TwitchBronBron merged 7 commits intov1from
limit_scope_revalidation_nov_2025
Nov 12, 2025
Merged

Limit scope Validation#1586
TwitchBronBron merged 7 commits intov1from
limit_scope_revalidation_nov_2025

Conversation

@markwpearce
Copy link
Collaborator

@markwpearce markwpearce commented Nov 1, 2025

At some point, the code was changed to run Scope.validate() on all scopes for every validation cycle, however, the step before that in the validation cycle, we find the list of scopes we actually need to re-validate.

This PR makes it so only the scopes that need it get revalidated.

Metrics (change of content of a string, so should not force any revalidation):

Before:

[07:47:35:564 PM][INFO ] prj0 Program.validate metrics:
    wait for previous run---------------------------------------------------- 000.009ms,   1 calls
    before and on programValidate-------------------------------------------- 000.230ms,   1 calls
    addDeferredComponentTypeSymbolCreation----------------------------------- 003.958ms,   2 calls
    addComponentReferenceTypes----------------------------------------------- 000.148ms,   1 calls
    beforeFileValidate------------------------------------------------------- 000.012ms,   2 calls
    onFileValidate----------------------------------------------------------- 009.268ms,   2 calls
    afterFileValidate-------------------------------------------------------- 005.460ms,   2 calls
    Build component types for any component that changes--------------------- 192.778ms,   1 calls
    track and update type-time and runtime symbol dependencies and changes--- 000.017ms,   1 calls
    tracks changed symbols and prepares files and scopes for validation.----- 513.915ms,   1 calls
    invalidate affected scopes----------------------------------------------- 000.061ms,   2 calls
    validate scopes---------------------------------------------------------- 000.050ms, 143 calls
    validate scope----------------------------------------------------------- 013.427ms, 143 calls
    afterScopeValidate------------------------------------------------------- 000.025ms, 121 calls
    detect duplicate component names----------------------------------------- 000.189ms,   1 calls
    Total-------------------------------------------------------------------- 739.546ms,  

After:

[07:51:33:737 PM][INFO ] prj0 Program.validate metrics:
    wait for previous run---------------------------------------------------- 000.008ms,   1 calls
    before and on programValidate-------------------------------------------- 000.145ms,   1 calls
    get files to be validated------------------------------------------------ 000.347ms,   1 calls
    add component reference types-------------------------------------------- 000.002ms,   1 calls
    beforeFileValidate------------------------------------------------------- 000.005ms,   2 calls
    onFileValidate----------------------------------------------------------- 005.200ms,   2 calls
    afterFileValidate-------------------------------------------------------- 003.739ms,   2 calls
    do deferred component creation------------------------------------------- 000.009ms,   2 calls
    build component types for any component that changes--------------------- 000.210ms,   1 calls
    track and update type-time and runtime symbol dependencies and changes--- 000.016ms,   1 calls
    tracks changed symbols and prepares files and scopes for validation------ 014.030ms,   1 calls
    invalidate affected scopes----------------------------------------------- 000.961ms,   2 calls
    checking scopes to validate---------------------------------------------- 000.026ms,   1 calls
    beforeScopeValidate------------------------------------------------------ 000.041ms, 121 calls
    validate scope----------------------------------------------------------- 015.807ms, 121 calls
    afterScopeValidate------------------------------------------------------- 000.044ms, 121 calls
    detect duplicate component names----------------------------------------- 000.314ms,   1 calls
    Total-------------------------------------------------------------------- 040.903ms,        

And this is for when there is a symbol change (in a file used in every scope):

Before:

[07:04:27:576 PM][INFO ] prj0 Program.validate metrics:
    wait for previous run---------------------------------------------------- 000.007ms,   1 calls
    before and on programValidate-------------------------------------------- 000.466ms,   1 calls
    addDeferredComponentTypeSymbolCreation----------------------------------- 008.305ms,   2 calls
    addComponentReferenceTypes----------------------------------------------- 002.212ms,   1 calls
    beforeFileValidate------------------------------------------------------- 000.024ms,   2 calls
    onFileValidate----------------------------------------------------------- 009.757ms,   2 calls
    afterFileValidate-------------------------------------------------------- 004.802ms,   2 calls
    Build component types for any component that changes--------------------- 422.268ms,   1 calls
    track and update type-time and runtime symbol dependencies and changes--- 000.018ms,   1 calls
    tracks changed symbols and prepares files and scopes for validation.----- 483.165ms,   1 calls
    invalidate affected scopes----------------------------------------------- 000.070ms,   2 calls
    validate scopes---------------------------------------------------------- 000.065ms, 143 calls
    validate scope----------------------------------------------------------- 015.748ms, 143 calls
    afterScopeValidate------------------------------------------------------- 000.044ms, 121 calls
    detect duplicate component names----------------------------------------- 000.183ms,   1 calls
    Total-------------------------------------------------------------------- 947.134ms,           

After:

[07:02:40:026 PM][INFO ] prj0 Program.validate metrics:
    wait for previous run---------------------------------------------------- 000.008ms,   1 calls
    before and on programValidate-------------------------------------------- 000.169ms,   1 calls
    get files to be validated------------------------------------------------ 000.368ms,   1 calls
    add component reference types-------------------------------------------- 000.004ms,   1 calls
    beforeFileValidate------------------------------------------------------- 000.005ms,   2 calls
    onFileValidate----------------------------------------------------------- 008.087ms,   2 calls
    afterFileValidate-------------------------------------------------------- 004.044ms,   2 calls
    do deferred component creation------------------------------------------- 003.033ms,   2 calls
    build component types for any component that changes--------------------- 000.167ms,   1 calls
    track and update type-time and runtime symbol dependencies and changes--- 000.022ms,   1 calls
    tracks changed symbols and prepares files and scopes for validation------ 561.109ms,   1 calls
    invalidate affected scopes----------------------------------------------- 000.481ms,   4 calls
    checking scopes to validate---------------------------------------------- 000.039ms,   1 calls
    beforeScopeValidate------------------------------------------------------ 000.056ms, 121 calls
    validate scope----------------------------------------------------------- 054.777ms, 121 calls
    afterScopeValidate------------------------------------------------------- 000.055ms, 121 calls
    detect duplicate component names----------------------------------------- 000.193ms,   1 calls
    Total-------------------------------------------------------------------- 632.618ms,      

@markwpearce markwpearce added this to the v1.0.0 milestone Nov 1, 2025
@markwpearce
Copy link
Collaborator Author

addresses #1496

@markwpearce markwpearce marked this pull request as draft November 1, 2025 22:48
@markwpearce
Copy link
Collaborator Author

markwpearce commented Nov 1, 2025

Huge improvement! Reduces re-validation by a factor of 10, when there's no potential changes to external files.

@markwpearce markwpearce marked this pull request as ready for review November 1, 2025 22:59
@markwpearce
Copy link
Collaborator Author

I think I can make this a little bit better.
component types should only be rebuilt when the symbols that are used for callfuncs change.
this should limit a bunch more revalidation

@markwpearce
Copy link
Collaborator Author

Ready for review, @TwitchBronBron

@TwitchBronBron TwitchBronBron merged commit cff33ee into v1 Nov 12, 2025
8 checks passed
@TwitchBronBron TwitchBronBron deleted the limit_scope_revalidation_nov_2025 branch November 12, 2025 19:40
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.

2 participants