This repository was archived by the owner on Dec 8, 2025. It is now read-only.
perf: speed up overlay performance ~200-40000x depending on the size of the document#17
Merged
ThomasRooney merged 3 commits intomainfrom Jul 7, 2025
Merged
perf: speed up overlay performance ~200-40000x depending on the size of the document#17ThomasRooney merged 3 commits intomainfrom
ThomasRooney merged 3 commits intomainfrom
Conversation
a0c2f84 to
63ac80d
Compare
TristanSpeakEasy
approved these changes
Jul 7, 2025
jamietanna
reviewed
Jul 7, 2025
| module github.com/speakeasy-api/openapi-overlay | ||
|
|
||
| go 1.22 | ||
| go 1.24 |
Contributor
There was a problem hiding this comment.
Did we need to bump this (and in a patch version)?
Coming from oapi-codegen/oapi-codegen#2017 and we try and keep a go directive compatability where possible, so this was a surprise to see in a patch release
(it's a great patch to improve performance 👏🏽)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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