-
Notifications
You must be signed in to change notification settings - Fork 7
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
Updated yrs to 0.18.2 #44
Conversation
@@ -184,23 +186,18 @@ impl YrsArray { | |||
arr.remove_range(tx, index, len) | |||
} | |||
|
|||
pub(crate) fn observe(&self, delegate: Box<dyn YrsArrayObservationDelegate>) -> u32 { | |||
let subscription_id = self | |||
pub(crate) fn observe(&self, delegate: Box<dyn YrsArrayObservationDelegate>) -> Arc<YSubscription> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this Arc return type. Again, I am not a Rust developer so I am not sure about the UniFFI generated code would not compile because it expected a type like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Horusiath what do you think about this? Do you think this is safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I'll greedily defer the Rust acceptability questions to @Horusiath , as feel very imposter every time I tackle something like that.
The two files in /scaffolding can be dumped from the PR, as they'll get regenerated by CI, but that doesn't strictly matter all that much - when we cut a release and punch in a new hash and XCFramework file during the release, they'll be regenerated as well.
I'll download the branch/PR and do some digging myself as to the memory leak. Off the top of my head, I suspect it's likely that because you made a YSubscription thing that passes over the Rust/Swift boundary, that this process is likely incurring a heavier cost, and I suspect related, but I'd need to dig a bit on the Swift side to see what I could find.
Thank you @heckj! Reverted the files you mentioned. import Foundation
import Combine
import XCTest
@testable import YSwift
class YSubscriptionTests: XCTestCase {
var document: YDocument!
var text: YText!
override func setUp() {
document = YDocument()
text = document.getOrCreateText(named: "test")
}
override func tearDown() {
document = nil
text = nil
}
// This causes memory to keep growing and I am not sure why
func test_allocateTooMany() {
for i in 1...1000000000 {
let s = text.observe { _ in }
text.unobserve(s)
if i % 1000000 == 0 {
print("\(Date()) Iterations: \(i) Resident Size: \(residentSize() ?? 0)")
}
}
print("Done!")
}
private func residentSize() -> UInt64? {
var info = mach_task_basic_info()
let MACH_TASK_BASIC_INFO_COUNT = MemoryLayout<mach_task_basic_info>.stride/MemoryLayout<natural_t>.stride
var count = mach_msg_type_number_t(MACH_TASK_BASIC_INFO_COUNT)
let kerr: kern_return_t = withUnsafeMutablePointer(to: &info) {
$0.withMemoryRebound(to: integer_t.self, capacity: MACH_TASK_BASIC_INFO_COUNT) {
task_info(mach_task_self_,
task_flavor_t(MACH_TASK_BASIC_INFO),
$0,
&count)
}
}
guard kerr == KERN_SUCCESS else {
return nil
}
return info.resident_size
}
} |
@heckj exciting that this was approved! CI is failing though, how can we fix that?
|
Back to fixing Tuist again? Damnit. I think it might be time to rip that out if it's not going to be stable. I'll work on getting a fix enabled there. And yeah, I'd still like @Horusiath 's input on that |
I couldn't update your branch, so I've opened #46, which will hopefully flow though smoothly. If that works, we can rebase this over latest main and see how it goes. I'm not 100% that this solves things, but I'm hopeful. |
@fbarbat Rebase this on the main branch, and it should be happier now... and I probably screwed up the current main branch, so if you need or want to regenerate the scaffold files to sort the rebasing, go for it - we'll get it fully sorted when we cut a release with this included. |
…e Subscription class
This reverts commit 38850fa.
Rebased, kept your changes and updated the PR! Wouldn't it be nice to remove the generated files from GitHub, add them to git ignore, and make Xcode to generate them on build? |
Normally, I'd love to, but the content in the scaffold files is tightly coupled to the XCFramework binary that's generated for the same, so for someone "coming along" and just wanting to use the code, they need to be there. For releases, we update everything in lockstep. For latest development on the |
All looks good with CI, tests passing, etc - so I'll hold on merging until you give me a thumbs up, in case you want to ask further questions. Once we merge this, I'll go ahead and do the leg-work to cut an updated release for more general consumption. |
I just realized I pushed some generated files changes (bad merge probably). Should I remove those? You mentioned those are regenerated on release... What do you think? |
Ok, I removed the changes to keep the PR cleaner. Can you run CI again? Thanks! |
This includes introducing a Subscription abstraction to get rid of the subscription IDs previously used that are not available anymore in Yrs.
#42