-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Diffing challenge: Swift vs Objective-C++ #76
Comments
@rnystrom is there a write-up for what the algorithm is? I can look through the EDIT: oops, found it! https://engineering.instagram.com/open-sourcing-iglistkit-3d66f1e4e9aa#.i4tl6xe0w |
@rnystrom IMHO it would also be really cool to have the diffing engine as a dependency to IGListKit, that way it can be used for other applications - diffing is useful in a number of other places, and especially when it's computable in Also, switching b/w the two implementations for you guys at Instagram to test performance would then just be changing one line in your (Pod/Cart)file 😄 |
@AndrewSB all the diffing is actually independent of the rest of the framework, just bundled w/ it so we aren't managing 2 projects where one (IGListKit) depends on the other (diffing). In fact, they used to be separate projects internally! We're tracking making a sub-podspec in #53 as well. Should be pretty easy. I like the idea about switching the algos on the fly though! Would be pretty cool. Oh you can find the original algorithm paper here. |
@rnystrom that makes sense for including just the diff engine in other projects, or I'm going to take a shot at the implementation in Swift over the next couple days - will be at https://github.com/AndrewSB/Diff. |
@AndrewSB amazing. I'll keep an eye on it, and if you run into issues or have questions, ping me on an issue there (or here). Happy to help out! |
Not sure what you mean by this.
|
Also: optimization levels should be the same:
Note that |
I think #2? I was more talking about using a protocol that called Objective-C methods on |
@rnystrom I mentioned you on an issue I was having AndrewSB/Diff#1 I've implemented a pretty naive version of Paul Heckel's algorithm in Diff.playground. There are a number of speed ups I know of already, but I wanted to get the algorithm outputting |
I went for the talk of Ryan in Singapore (great talk btw) and tried porting it to Swift. https://github.com/lxcid/ListDiff This is done is Swift 3 and depends only on Foundation. Its in a single file so you guys can just copy into your project. Let me know if you find any bug. Thanks for the reference implementation. It very interesting and I learnt quite a bit. Equality check is not implemented yet because I haven't figure out the API interface. |
@lxcid can you do Algorithm looks good tho! Funny how it looks basically the same considering its C++ and Swift. |
Thanks! Yeah, it was a direct port from IGListKit, much of the structural part of the code was kept similar. 😅 Was surprise to see that the A workaround is to drop support for I haven't test out yet though… |
@lxcid re: pointer personality, that makes sense! I guess we could just stick to func ==(lhs: MyClass, rhs: MyClass) -> Bool {
return lhs === rhs || lhs.value == rhs.value
} Then structs are always just value comparisons. |
Ahhh didn't thought about that. I agree! |
@rnystrom did you end up testing the swift version? Was it any faster? |
I'm proposing this mostly for fun/learning. We spent a lot of time optimizing our diffing algorithm in Objective-C++ (e.g. custom
unordered_map
, tables, structs). It's blazing fast, but I'm really curious how it would perform in Swift.Parameters:
@objc protocol IGListDiffable { ... }
objc_msgSend(...)
fordiffIdentifier
andisEqual:
-Os
for Objective-CMy hunch is that the current implementation will be faster, but I'd love to be proven wrong!
The text was updated successfully, but these errors were encountered: