-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SR-1005: Replace POSIX module by Foundation #284
Conversation
Awesome! For test crashes, you should be able to run the tests in a debugger to see what is actually happening. Can you file bugs for the places where the Foundation API differs across platforms? It would be good to identify the source of the performance regression, as well. |
The segfault as reported by the LLDB debugger, however I'm not sure how to proceed.
API differences reported in SR-1328. I suspect that the performance regressions are expected as the old POSIX calls are very lean. The new calls using Foundation probably contain extra error checking; more layers of indirection. |
This probably isn't the case. While it is true there is a little more indirection, that is unlikely to be able to add up to 6% given the kind of work we are doing... my guess is something else is going on here. Can you try to identify a particular individual test which has regressed? |
That was indeed the case. Some NSFileManager functions performed even slightly better in a quick performance test. The full test suite is now run as fast as before. |
Great stuff. Let's deconflict and merge. |
Thanks! Indeed it does conflict, it was written against the latest development toolchain snapshot. The Foundation API is being imported now with new rules, so I'm unable to compile until I have an updated toolchain. I've yet to learn to build my own toolchain, maybe I'll just wait for a new toolchain snapshot. |
I've located the segfaults on Linux to be related to |
ee28942
to
ca6fd84
Compare
I've rebased the PR and verified against OSX and Ubuntu 15.10. |
I've also moved |
Can you rebase please? |
c10ef55
to
9eed36c
Compare
@swift-ci please test and merge |
|
||
import func libc.unlink | ||
import var libc.errno | ||
import Foundation | ||
|
||
public func unlink(_ path: String) throws { |
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.
This function should be renamed, using unlink
as a synonym for removing a tree is confusing, as that is not the POSIX behavior.
@swift-ci please test |
Any ideas on why the build failed on OSX? The logs include the following test case, but I'm not sure how that's related?
|
That is unrelated, it sounds like from mail on swift-dev. |
Can you retest? |
@swift-ci please test |
@Bouke conflicts |
Dropped relativeTo argument as it wasn't used.
The rmtree is not needed as directories are already removed recursively.
@ddunbar @aciidb0mb3r rebased and tested against OSX and Ubuntu 15.10. |
@swift-ci please test |
I am going to start pulling over individual parts of this piecemeal for things that make more sense to be implemented on top of Foundation than POSIX wrappers... |
I posted a new PR #355 which cherry picks (and reworks) a couple of commits from this PR. The ones I took: The ones I abandoned, and why:
|
A partial implementation of SR-1005, replacing POSIX calls by Foundation calls. This PR addresses most file and directory operations by using NSFileManager and NSURL. To prevent a major overhaul of all usages of these calls, I kept all functions intact but changed the implementation. Some things to consider before merging this PR:
#if os(Linux)
for the interim until this is fixed.unlink
andrmdir
both useNSFileManager.removeItem(atPath:)
, which will remove files and directories recursively. The old implementations ofunlink
would only remove files, andrmdir
would only remove directories non-recursive.mkdir
returns relative folder name if relative name was passed. Userealpath(mkdir(...))
when old functionality is wanted; opt-in for absolute paths.*time*
,readlink
,stat
) were removed.relativeTo
argument ofsymlink
as it was not used; all usages used an absolute path.Not covered by this PR:
popen
andsystem
by NSTask, see SR-1005: [Foundation] Replace posix_spawn by NSTask #303Dependencies: