-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify stack #738
Simplify stack #738
Conversation
Codecov Report
@@ Coverage Diff @@
## master #738 +/- ##
==========================================
+ Coverage 76.89% 77.05% +0.16%
==========================================
Files 38 38
Lines 2445 2467 +22
==========================================
+ Hits 1880 1901 +21
- Misses 565 566 +1
Continue to review full report at Codecov.
|
So the main change here is that the stack is no longer a big nested layer type, but a linked list of This is a pretty large change to the original design which very explicitly aimed to avoid runtime dispatch. Maybe that's fine in the name of simplifying things and I've wondered about this myself. But I think testing against Unfortunately we don't have the original author of the current design around anymore to ask for advice and motivating examples. |
Thanks for taking a look at the PR. I just figured that my whole PR is based on a wrong assumption. I thought that the I could still rewrite this PR to simplify the huge ternary statement in |
Ah I see. Well, this isn't entirely true, but it may be partially true — while dispatch happens based on the individual layer types, specialization may happen based on the concrete type of the stack from the current layer downward (though the exact amount of specialization is an implementation detail of the compiler). Personally I think it would be interesting and useful to change the stack into a stack of layer instances rather than types. Then the layers can contain state if necessary (for example, the connection pool layer would no longer need to rely on global state). If you do want to consider this design further, I'd suggest abstracting the stack such that implementation of individual layers is decoupled from the concrete representation of the stack. Then users could choose their stack representation to hide information from the compiler (as in your |
Fair enough. Well, in Julia 1.7 it looked fine when inspecting
I don't think anymore that there is much to gain here, so probably not 🙂 |
This PR reduces compilation latency and simplifies the logic around
HTTP.stack
. As a side-effect, also #469 should be fixed now. The benchmarks below are on Julia 1.7-beta3.0.master:
this PR:
So, about 4% reduction in allocations and half a second shorter compilation time on the first request. The difference gets bigger when users make multiple types of requests:
master:
this PR:
This is a reduction in allocations of 5.6 %.
The reason that this PR reduces the latency is that
HTTP.request
was specialized on too much. For each different stack,HTTP.request
got multiple different new methodinstances.These changes should not affect the runtime. It would technically be possible to define a
Stack{U,V}
type which would allow all theHTTP.request
s to avoid runtime dispatch. However, since some request methods are quite large, I don't think that the extra memory consumption would be worth it.Runtime benchmark for master
Runtime benchmark for this PR