chore: add benchmark showing a 2.5 reduction in memory usage since RC2 #298
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.
This benchmark shows that #292 and #293 improve memory usage by a factor of 2.5!
The more data read from the request body or written in the response body, the more significant the improvement!
There is still room for similar improvements in:
frankenphp/frankenphp.go
Line 509 in 981f954
It would be nice if the memory wasn't allocated once in Go and a second time in C (and then a third time because of how PHP works internally). A possible way to improve this could be to populate the CGI variables directly in C-compatible strings, to avoid copyinv.
Before #292 and #293.
Memory usage: 14.9 bytes per request.
goos: darwin
goarch: arm64
pkg: github.com/dunglas/frankenphp
BenchmarkEcho
BenchmarkEcho-8 3514 342450 ns/op 15261 B/op 32 allocs/op
PASS
ok github.com/dunglas/frankenphp 2.122s
After
5.3 bytes per request.
goos: darwin
goarch: arm64
pkg: github.com/dunglas/frankenphp
BenchmarkEcho
BenchmarkEcho-8 3565 335976 ns/op 5482 B/op 28 allocs/op
PASS
ok github.com/dunglas/frankenphp 2.150s