Repository navigation
[Vsintegration] Solution open: no VACUUM of the code model database - #2191
Merged
RobertvanderHulst merged 1 commit intoNov 21, 2026
Merged
Conversation
SetPragmas ran a VACUUM for every connection, and CreateOrOpenDatabase opens the disk database twice: two full rewrites of the file on the UI thread for every solution that opens (15 s for a 284 MB database). SaveToDisk compacts the file after every backup, and a file written by the other SQLite provider is rejected by ValidateSchema (Db_Version.MsSqlite). For Microsoft.Data.Sqlite, whose NOCASE depends on the culture, the NOCASE indexes of the in memory copy are rebuilt after the restore instead. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opening a solution froze Visual Studio while the code model database was opened:
SetPragmasran aVACUUMfor every connection, andCreateOrOpenDatabaseopens the disk database twice. That is two full rewrites of the.xsdbon the UI thread for every solution that opens, in both project systems (MPFproj and CPS).XSolution.Open # UI thread XDatabase.CreateOrOpenDatabase OpenFile(disk) # for ValidateSchema SetPragmas foreign_keys, SetCollation - VACUUM # 3.3 s ValidateSchema # rejects a file of the other SQLite provider (Db_Version.MsSqlite) OpenFile(disk) # for the restore SetPragmas - VACUUM # 12.0 s RestoreFromDisk # 0.3-0.6 s + ReindexAfterRestore # Microsoft.Data.Sqlite only: REINDEX NOCASE on the in memory copy DeleteOrphanFiles, DeleteMissingFilesVACUUMat open also re-sorted theNOCASEindexes of a file that the other SQLite provider wrote ([Vsintegration] XDatabase: register the collation before the VACUUM #2132). Since 9b3fe5fValidateSchemarejects such a file, so with System.Data.SQLite (built-inNOCASE) theVACUUMhad nothing left to do.SaveToDiskstill compacts the file after every backup.NOCASEthat compares with the current culture, so the order of an index can still differ from the one the file was written with. For that provider theNOCASEindexes of the in memory copy are rebuilt after the restore, which is what theVACUUMdid at that point.Evidence
VS 2022 (17.14) experimental instance, SDK-style solution with 94 X# projects x 2 target frameworks, 45,800 files, 284 MB
X#Model.xsdb, warm open, System.Data.SQLite. UI responsiveness probed every 250 ms withSendMessageTimeout; database times from the X# log (one run each).CreateOrOpenDatabase(log)XDatabase.SetPragmas<-OpenFile<-CreateOrOpenDatabase<-XSolution.Open.AddFilecalls, no errors in the log, no re-parse of the sources: the database is taken over completely.Microsoft.Data.Sqlite was not run inside Visual Studio. Outside, with that provider and the custom
NOCASEon a copy of the same file (written with the built-inNOCASE):PRAGMA integrity_checkreportsrow 236 missing from index ReferencedTypes_Nameafter the restore,REINDEX NOCASEtakes 6.0 s, and the check then returnsok.Merge Danger
Door: two-way
No change to the database format or schema version; reverting the commit restores the old behaviour.
Blast Radius: code model database open
With Microsoft.Data.Sqlite (ARM, or the option) the open still costs one
REINDEX(6 s on this database) on the UI thread, instead of twoVACUUMs. Dropping that as well needs a culture marker in the file or a culture independent collation, which changes the database format and is left out here.🤖 Generated with Claude Code