-
Notifications
You must be signed in to change notification settings - Fork 47
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
Type-checking Performance #83
Comments
Thanks for the report. I’m curious whether you’re using the batching for particular performance reasons, or to get disabled constraints, or just as a catch-all? We usually don’t use it unless we have a performance hotspot. Also, it would be cool to revisit batch using function builders! |
So I've given it some thought and my best guess is that the type checker is checking of all possible ways to resolve My best guess is that the type checking performance would increase if there were some other operators than I don't have time now to test my hypothesis, but I'm planning on doing that some time in the future |
Operator overloads are the slowest to type-check, and have (IIRC) exponential time complexity. It would likely be a lot faster to avoid operators and use named functions instead. |
@chrisballinger .. which kills all the beauty of using anchorage in the first place :) |
skate to where the operator overload type checking performance puck is going to be 😉⛸🏒 |
Its really nice tool, but build time is killing me ;/ i'm seeing 3 major advantages of this solution:
|
I could definitely see the advantage of splitting things out so that the operators become sugar over a set of methods. Anchorage provides so many niceties, like setting All that said, I'm even more interested in finding out what can be done to improve compilation time. Now that we support SPM, I might look into submitting this repo to the various Swift compatibility suites and performance benchmarks. |
Cartography has a similar issue with overloaded operators increasing compile times. There's a PR to add custom operators replacing the overloaded operators that significantly decreases compile times: robb/Cartography#293 It would be nice for this to be fixed in Swift itself but I don't know if that's possible |
A nice first step would be to add Anchorage to the Swift Source Compatibility Test Suite: #40 |
We're using anchorage in our app and have something akin to this in our xcconfig:
OTHER_SWIFT_FLAGS = -Xfrontend -warn-long-function-bodies=400 -Xfrontend -warn-long-expression-type-checking=400
We compile Anchorage from source due to needing a static lib and Anchorage code as well as our app are consistently causing warnings.
For Anchorage, it's the
performInBatch(closure:)
call infunc constraints(forAnchors:, firstConstant c1:, secondConstant:, priority:, builder:)
(Internal.swift
).In our app, functions that have numerous calls to
Anchorage.batch(active:closure:)
ini the same function tends to also fail this check.The text was updated successfully, but these errors were encountered: