perf: speed up overlay performance ~200-40000x depending on the size of the document #17
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.
Context:
Strict Mode effectively produced a warning when there was an overlay action that didn't do anything.
It was done by serialising the document before and after each change and doing a comparison. Super inefficient.
This makes it work by returning back a "didChange" boolean all the way from applyNode depending on the kind of change that happened.
From:
cpu: Apple M3 Max
BenchmarkApplyToStrictBySize
BenchmarkApplyToStrictBySize/2KB
apply_test.go:206: OpenAPI size: 16911 bytes (target: 2048, paths added: 0)
BenchmarkApplyToStrictBySize/2KB-14 738 1600568 ns/op
BenchmarkApplyToStrictBySize/20KB
apply_test.go:206: OpenAPI size: 22741 bytes (target: 20480, paths added: 16)
BenchmarkApplyToStrictBySize/20KB-14 493 2377933 ns/op
BenchmarkApplyToStrictBySize/200KB
apply_test.go:206: OpenAPI size: 245551 bytes (target: 204800, paths added: 625)
BenchmarkApplyToStrictBySize/200KB-14 48 23456246 ns/op
BenchmarkApplyToStrictBySize/2M
apply_test.go:206: OpenAPI size: 2477637 bytes (target: 2048000, paths added: 6708)
BenchmarkApplyToStrictBySize/2M-14 5 235112558 ns/op
PASS
To:
BenchmarkApplyToStrictBySize
BenchmarkApplyToStrictBySize/2KB
apply_test.go:206: OpenAPI size: 16911 bytes (target: 2048, paths added: 0)
BenchmarkApplyToStrictBySize/2KB-14 200113 6067 ns/op
BenchmarkApplyToStrictBySize/20KB
apply_test.go:206: OpenAPI size: 22741 bytes (target: 20480, paths added: 16)
BenchmarkApplyToStrictBySize/20KB-14 192753 6248 ns/op
BenchmarkApplyToStrictBySize/200KB
apply_test.go:206: OpenAPI size: 245551 bytes (target: 204800, paths added: 625)
BenchmarkApplyToStrictBySize/200KB-14 170931 7046 ns/op
BenchmarkApplyToStrictBySize/2M
apply_test.go:206: OpenAPI size: 2477637 bytes (target: 2048000, paths added: 6708)
BenchmarkApplyToStrictBySize/2M-14 216870 5873 ns/op
PASS