Skip to content

perf(util): replace global RWMutex with sync.Map in reCache to eliminate mutex contention (fix #1690) - #1750

Open
Jaymr1031-Z wants to merge 1 commit into
apache:masterfrom
Jaymr1031-Z:perf/regex-sync-map-cache
Open

perf(util): replace global RWMutex with sync.Map in reCache to eliminate mutex contention (fix #1690)#1750
Jaymr1031-Z wants to merge 1 commit into
apache:masterfrom
Jaymr1031-Z:perf/regex-sync-map-cache

Conversation

@Jaymr1031-Z

Copy link
Copy Markdown

Fixes #1690

Problem

In util/builtin_operators.go, mustCompileOrGet() guarded regex cache access with a global sync.RWMutex (
eCacheMu). Under high-throughput concurrent policy evaluation across multiple goroutines, the mutex lock contention created unnecessary bottlenecks.

Solution

  • Replace
    eCache (map[string]*regexp.Regexp) and
    eCacheMu (sync.RWMutex) with a thread-safe, lock-free sync.Map.
  • Use
    eCache.Load and
    eCache.LoadOrStore inside mustCompileOrGet for lock-free read-heavy access.

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.

[feature] change all regex in xxx match functions to pre-compiled to boost performance

1 participant