Skip to content

fix: restore timing, bound parallelism, stabilize output ordering in view generation#2

Merged
Raylopi merged 2 commits into
mainfrom
copilot/optimize-ef6-view-generation
Apr 3, 2026
Merged

fix: restore timing, bound parallelism, stabilize output ordering in view generation#2
Raylopi merged 2 commits into
mainfrom
copilot/optimize-ef6-view-generation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

The existing parallelization of EF6 view generation (OPT-1/2/3) had three defects introduced during the refactor.

Fixes

  • Missing timing in sequential pathSetTimeForFinishedActivity was removed from GenerateDirectionalViewsForExtent and only restored in the parallel branch. The sequential fallback (GenerateDirectionalViewsSequential, hit when extent count ≤ 1) never recorded PerfType.QueryViews/UpdateViews timing.

  • Unbounded parallelism — Both Parallel.ForEach calls (cell groups in ViewgenGatekeeper, extents in ViewGenerator) used default scheduler with no degree limit, risking ThreadPool saturation under hosted contexts (IIS, VS). Added MaxDegreeOfParallelism = Environment.ProcessorCount.

  • Non-deterministic output orderingConcurrentBag enumeration order is arbitrary. PowerTools serializes the view dictionary to a .cs file, so unstable ordering causes spurious diffs. Views are now sorted by EntitySetBase.Name (ordinal) before merge.

Files changed

  • ViewGenerator.cs — all three fixes
  • ViewgenGatekeeper.cs — parallelism bound + ordering

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pdfvsblobprodcus380.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet restore EntityFramework.sln (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build src/EntityFramework/EntityFramework.csproj -f netstandard2.1 --no-restore (dns block)
  • uy6vsblobprodcus34.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build src/EntityFramework/EntityFramework.csproj -f netstandard2.1 --no-restore (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

…nsure deterministic view ordering

Agent-Logs-Url: https://github.com/Raylopi/ef6/sessions/d872e6fc-716c-4129-85db-5ccf24cc2577

Co-authored-by: Raylopi <54796610+Raylopi@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize EF6 view generation for databases with 500+ tables fix: restore timing, bound parallelism, stabilize output ordering in view generation Apr 3, 2026
Copilot AI requested a review from Raylopi April 3, 2026 08:17
@Raylopi Raylopi requested a review from Copilot April 3, 2026 08:24
@Raylopi Raylopi marked this pull request as ready for review April 3, 2026 08:25
@Raylopi Raylopi review requested due to automatic review settings April 3, 2026 08:26
@Raylopi Raylopi merged commit 05f01eb into main Apr 3, 2026
3 checks passed
@Raylopi Raylopi deleted the copilot/optimize-ef6-view-generation branch April 3, 2026 08:27
Raylopi added a commit that referenced this pull request Apr 3, 2026
… view generation

Implement Parte 1 of Issue #2: Public API in StorageMappingItemCollection that
generates views for a subset of entity sets (cell groups) only.

Changes:
- Add StorageMappingItemCollection.GenerateViewsIncremental(ISet<string>
  entitySetNamesToRegenerate, IList<EdmSchemaError> errors) public method

  Returns IReadOnlyDictionary<EntitySetBase, DbMappingView> containing ONLY
  views of regenerated groups. Caller responsible for merging with cached views.

- Add ViewgenGatekeeper.GenerateViewsFromMappingIncremental() entry point

- Add optional entitySetNameFilter parameter to GenerateViewsFromCells()

  After CellPartitioner groups cells, filters to keep only groups that contain
  at least one extent whose name is in entitySetNameFilter. All validation
  (CellGroupValidator, FK constraints) still runs on regenerated groups.

Architecture:
- If entitySetNameFilter is null: generates all views (backward compatible)
- If entitySetNameFilter has names: expands to full cell groups via FK/entity-split
  graph and regenerates only those groups
- Returns only views for changed entity sets (VSIX merges with cache)

Integration point for VSIX incremental generation: VSIX calls via reflection to
check if GenerateViewsIncremental exists, uses it if available with delta-detected
entity sets, falls back to full GenerateViews() on EF6 stock or if method absent.

Expected impact: On a model with 500+ tables where only 3 entities changed,
regenerates only the affected cell groups instead of all ~20 groups, reducing
view gen time from 6+ minutes to <10 seconds.
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.

perf: ottimizzare la view generation di EF6 per database con 500+ tabelle

2 participants