Skip to content

Improve performance for application-configuration with large number of permissions#25231

Merged
EngincanV merged 3 commits intorel-10.3from
perf/improve-application-configuration-with-large-permissions
Apr 10, 2026
Merged

Improve performance for application-configuration with large number of permissions#25231
EngincanV merged 3 commits intorel-10.3from
perf/improve-application-configuration-with-large-permissions

Conversation

@maliming
Copy link
Copy Markdown
Member

@maliming maliming commented Apr 10, 2026

When a project has 4000+ permissions, /api/abp/application-configuration takes 10s+. Even with Redis caching it stays slow (~1.45s locally) because the bottleneck is in the application layer. A temporary patch reduced customer production time from 10s+ to ~682ms.

Changes:

  • SimpleStateCheckerManager.InternalIsEnabledAsync: skip ServiceProvider.CreateScope() when both StateCheckers and GlobalStateCheckers are empty
  • PermissionChecker.IsGrantedAsync(string[]) / ResourcePermissionChecker.IsGrantedAsync(string[], ...): load all permission definitions once via GetPermissionsAsync instead of N individual GetOrNullAsync calls; use batch StateCheckerManager.IsEnabledAsync
  • GetAuthConfigAsync: pre-load permission names into a HashSet for O(1) lookup instead of N async calls in the loop
  • GetResourcePermissionsAsync: fix deduplication key from Name to (ResourceName, Name) — resource permissions are unique by both fields, same name can exist for different resources

Copilot AI review requested due to automatic review settings April 10, 2026 07:35
…f permissions

- Replace FormattedStringValueExtracter.Extract with LastIndexOf in
  PermissionGrantCacheItem and ResourcePermissionGrantCacheItem to
  eliminate repeated string tokenization and object allocations on
  every cache key parse (~12,000 calls per request with 4000+ permissions)

- Add fast-path in SimpleStateCheckerManager.InternalIsEnabledAsync to
  skip DI scope creation when both StateCheckers and GlobalStateCheckers
  are empty, avoiding thousands of unnecessary scope allocations

- Optimize PermissionChecker.IsGrantedAsync(string[]) and
  ResourcePermissionChecker.IsGrantedAsync(string[], resourceName, resourceKey)
  to load all permission definitions once via GetPermissionsAsync /
  GetResourcePermissionsAsync instead of N individual GetOrNullAsync calls,
  and use batch StateCheckerManager.IsEnabledAsync for state checking

- Optimize AbpApplicationConfigurationAppService.GetAuthConfigAsync to
  pre-load all permission names into a HashSet for O(1) lookup instead
  of N async GetOrNullAsync calls inside the loop

- Fix GetResourcePermissionsAsync to deduplicate by (ResourceName, Name)
  instead of Name only, matching the actual uniqueness constraint of
  resource permissions defined in PermissionDefinitionContext

Production impact (customer with 4000+ permissions): 10s+ -> ~682ms
@maliming maliming force-pushed the perf/improve-application-configuration-with-large-permissions branch from d5509c6 to 67ebd58 Compare April 10, 2026 07:37

This comment was marked as off-topic.

@maliming maliming added this to the 10.3-final milestone Apr 10, 2026
@maliming maliming requested a review from Copilot April 10, 2026 07:38

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

@maliming maliming requested a review from EngincanV April 10, 2026 09:02
@maliming maliming marked this pull request as draft April 10, 2026 09:05
@maliming maliming marked this pull request as ready for review April 10, 2026 09:38
@EngincanV EngincanV merged commit d1c108b into rel-10.3 Apr 10, 2026
8 checks passed
@EngincanV EngincanV deleted the perf/improve-application-configuration-with-large-permissions branch April 10, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants