Closed ScottRobbins closed 5 years ago
will cacheing hashvalues provide a performance benefit?
https://forums.swift.org/t/accepted-se-0206-hashable-enhancements/11675/18?u=scott (for how to cache hash values)
If I immediately cache the hash value of layout constraints, can I do the constraint diffing on a different thread while the other view hierarchy stuff is running?
My guess is that this won't help much. I should also see how much time is actually spent on constraint diffing vs the rest of it. It may be a good idea to make a chart of how much time is spent for some specific example on each part. maybe play with os_signpost
for that.
Implemented cacheing hashValues: https://github.com/HotCocoaTouch/DeclarativeLayout/pull/33
If I immediately cache the hash value of layout constraints, can I do the constraint diffing on a different thread while the other view hierarchy stuff is running?
No, because the actual equatable work relies on the main thread to access the real views to compare instances.
I'm still unsure if this applies to diffing since I won't be manipulating UIViews in the background, just checking if one is equal to another. Assuming that testing equality in the background is thread safe, will it still print shit in the console anyway? If so, that may be enough to not make it a good solution, as people will think it is unsafe.
I suppose I could probably also grab its layer, which is thread safe, to do comparing in the background. but in all honesty there probably aren't enough constraints to diff to make the overhead of context switching worth it.
Since 0.9.0 might change the model of how this whole thing works anyway, I'm not going to do more optimizations in 0.8.0
In 0.7.0 I did optimizations and then added new features without a lot of consideration for optimization
In 0.8.0 I should take a look again at the things I added and see if there's room for improvement, also look into compiler annotations like
@inlineable
and see if any of those can help.