You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use json-patch in our project and observed a performance difference when we upgraded to v5 from an older version. This is a high scale application which is particularly sensitive to memory allocations. I turned the MergePatch example in the readme to a benchmark test and found the following results on the 5.2.0 and 5.1.0 version branches with Go 1.16:
func BenchmarkMergePatch(b *testing.B) {
original := []byte(`{"name": "John", "age": 24, "height": 3.21}`)
target := []byte(`{"name": "Jane", "age": 24}`)
alternative := []byte(`{"name": "Tina", "age": 28, "height": 3.75}`)
patch, err := CreateMergePatch(original, target)
if err != nil {
panic(err)
}
for n := 0; n < b.N; n++ {
MergePatch(alternative, patch)
}
}
v5.2.0+ is using significantly more memory in terms of bytes and allocations. I am curious if this is a known change or perhaps we need to modify our calls to optimize for lower memory usage?
Activity
[-]Performance Degradation v4 to v5[/-][+]Performance Degradation Starting In v5.2.0[/+]evanphx commentedon Jan 12, 2024
Sorry for the long delay, I'm looking into this. Part of the reason is some correctness fixes.
SyntaxNode commentedon Jan 12, 2024
No worries. Thank you for the fix.