-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deepcopy cached value instead of unmarshalling json (#1439)
Instead of keeping the assigned value for AssignMutator as json, cache the unmarshalled value. Unmarshalling JSON is incredibly expensive, even for simple values. We should avoid this when possible. Instead, we should cache the value to assign, and then deepcopy it when needed. Fortunately, the runtime package provides us a method just for this! This change results in a ~90% reduction in compute time for most common uses. The existing benchmarks are for assigning a string, but the speedup is even more for complex assigned values. Signed-off-by: Will Beason <willbeason@google.com>
- Loading branch information
Will Beason
committed
Jul 20, 2021
1 parent
55a042e
commit 812b7c6
Showing
2 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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