Repository navigation
perf: skip redundant mappertag rebuild - #98
Merged
bxcodec merged 3 commits intoJul 25, 2026
Merged
Conversation
…ebuild Rename: this fork needs its own import path so a downstream module (mockagen) can require it directly instead of via a bare local replace against the upstream module path. Perf fix: FakeData() called initOption() -> initMapperTagWithOption() on every single invocation, unconditionally re-storing ~9 Internet/Networker generator functions into the global mapperTag map regardless of whether any per-call options were actually passed. Profiling a high-volume concurrent caller (github.com/catdevman/mockagen, ~1M+ FakeData calls across many goroutines) showed this was a significant share of total CPU time, plus lock contention on mapperTag from doing it concurrently on every call. Guard the common case (no per-call options, i.e. plain faker.FakeData(&v)) behind a sync.Once so the map is only populated once instead of on every call. Calls that do pass options still re-run every time, so existing per-call customization (e.g. a custom email domain option) is unaffected.
Guard the no-options case behind sync.Once to avoid re-populating the global mapperTag map on every call, cutting repeated work and lock contention.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #98 +/- ##
==========================================
+ Coverage 81.09% 81.31% +0.22%
==========================================
Files 16 16
Lines 2174 2184 +10
==========================================
+ Hits 1763 1776 +13
+ Misses 352 350 -2
+ Partials 59 58 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bxcodec
approved these changes
Jul 25, 2026
bxcodec
left a comment
Contributor
There was a problem hiding this comment.
Nice!
LGTM
Thanks for the PR @catdevman
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.
The will close #97