Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: improve performance for parsePostForm #14655
My main concern is using
Instead I think using a
I've implemented the solution and added a benchmark to show you the performance improvements.
First of, here's the benchmark:
Now here's the first run of the benchmark before the improvement:
You can see that
Now here's the result of the benchmark after the improvement I suggest:
The very same command, this time at line 911, now eats only
If you need any extra information please let me know.
If you think this performance proposal is sound I'll mail the change for review using
Actually, instead of a
(In the future, it might be nice to not even allocate for the common map keys, since most http.Handlers receiving POSTs will be getting the same map keys repeatedly. But there's no great place to stash that cache, since we don't know which handler the request is for (yet). We might know that later, if #14660 happens, since we could associate a Handler with a Request via context keys... but that's just thinking ahead and not needed for addressing this garbage)
OK so to avoid adding a public API I've added a
Is that what you had in mind ?
Because running the same benchmark gives me worse results than the last 2 benchmarks :
Just by looking at this result we can see that it's 3 times slower and allocates as much as the original implementation (since this time it only does 500 repetitions vs 2000 last time)
Is there any particular reason you don't want to go the
If you still do, is there anything I've misinterpreted from your guidelines that would worsen the benchmark ?