Skip to content

File list support #144

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

Merged
merged 6 commits into from
Sep 12, 2020
Merged

File list support #144

merged 6 commits into from
Sep 12, 2020

Conversation

cltnschlosser
Copy link
Contributor

@cltnschlosser cltnschlosser commented Jun 28, 2020

Major changes:

  • VirtualPath enum case addition: case fileList(RelativePath, FileList)
  • ArgsResolver handles fileList case.
  • ArgsResolver is now reference type since it should only write each file list once.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I'd like to hear your thoughts on my alternative modeling for the file list files themselves

@cltnschlosser
Copy link
Contributor Author

Okay, still a bit of work todo. Need to refactor the FileList object and ArgsResolver (also add the new VirtualPath case). Then need to write tests for everything, there are a lot of little edge cases caught by the lit tests.

Also I want to pull out a few changes into other smaller PRs.

Newly passing:
Driver/batch_mode_with_supplementary_filelist.swift
Driver/batch_mode_with_supplementary_filelist_unicode.swift
Driver/emit-interface.swift
Driver/filelist-threshold.swift

Mostly working (Just temporary file handling, and some path formatting(I can open swift PR for this)):
Driver/filelists.swift

Issues with Driver/filelists.swift:

  • Extra temporary directory layer
  • Temporary files not removed on failure (C++ driver tracks all temporary files and deletes them after it's done. Unless -save-temps is passed, or the job crashes and the files are marked to be saved on signal)

@cltnschlosser
Copy link
Contributor Author

@DougGregor I've hit a snag in the ArgsResolver managing which filelists are written. In order to make the ArgsList actually keep track of this state it needs to be a class (or needs to be provided access to something else that tracks this state). Because two compile jobs can use the same filelist, the ArgsResolver then needs to use locking. Previously two jobs could resolve their arguments entirely in parallel.

I'm going to move forward with the locking to see how it works out, but it does seem less than ideal.

@cltnschlosser cltnschlosser force-pushed the cs_fileLists branch 2 times, most recently from 9ef58e3 to 4768b9e Compare August 18, 2020 03:52
@cltnschlosser cltnschlosser marked this pull request as ready for review August 18, 2020 03:56
@cltnschlosser
Copy link
Contributor Author

Okay, rebased this. Most tests are failing locally due to could not decode frontend target info; compiler driver and frontend executables may be incompatible. I'm using the latest toolchain on swift.org for xcode.

@DougGregor
Copy link
Member

Okay, rebased this. Most tests are failing locally due to could not decode frontend target info; compiler driver and frontend executables may be incompatible. I'm using the latest toolchain on swift.org for xcode.

Maybe you're picking up the Swift compiler/frontend executable from the default toolchain. If you haven't don't so yet, I suggest overriding the environment variable SWIFT_DRIVER_SWIFT_FRONTEND_EXEC to point at the swift-frontend executable in the toolchain you downloaded. (And make sure it's a master toolchain; these changes aren't in 5.3)

@cltnschlosser
Copy link
Contributor Author

Maybe you're picking up the Swift compiler/frontend executable from the default toolchain

Yep, this was it. I'm hard coding it now for testing. Looks like xcrun --find only looks inside the default toolchain.

There might be some legitimate failures.

@cltnschlosser
Copy link
Contributor Author

Environment variable works as well. Using that now :)

@cltnschlosser
Copy link
Contributor Author

I think the only TODO that is left is to port some of the lit tests to XCTest, so we have coverage here.

Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really great!

@@ -1730,7 +1782,7 @@ extension Driver {
return path
}

return path.parentDirectory.appending(component: "\(moduleName).\(type.rawValue)")
return path.replacingExtension(with: type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and/or the change at line 1889 will break the Driver/opt-record.swift integration test, getting these path computations to match the c++ driver has been really challenging due to the architectural differences between the two implementations. Maybe we can get away with just picking better defaults in swift-driver since most clients that care about these outputs are already using output file maps...

Either way, if this can't be fixed yet and we have to make a choice between file list and optimization record tests passing in the short term, I'd choose file lists 😄

Comment on lines +346 to +359
// Question: outputs.count > fileListThreshold makes sense, but c++ does the following:
if primaryInputs.count * FileType.allCases.count > fileListThreshold {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the c++ driver has to overestimate here because it doesn't know how many outputs there will be when it does this calculation. It should be ok to use a tighter bound here if possible

Comment on lines +403 to +416
// I don't like this as a global function, but it needs to be used by both Driver and Toolchain
func createTemporaryFileName(prefix: String, suffix: String? = nil) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the ArgsResolver could be responsible for appending the number? Not sure if that would help much.

Comment on lines +116 to +122
// This uses Yams to escape and quote strings, but not to output the whole yaml file because
// it sometimes outputs mappings in explicit block format (https://yaml.org/spec/1.2/spec.html#id2798057)
// and the frontend (llvm) only seems to support implicit block format.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can confirm the llvm yaml parser doesn't handle explicit block format unfortunately

@cltnschlosser
Copy link
Contributor Author

Okay, rebased. Resolved concerns from comments and added tests. Should be all good now :)

@owenv
Copy link
Contributor

owenv commented Sep 12, 2020

@swift-ci please test

Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything here looks good to me, thanks again for working on this!

I do think we'll want to rework the temporary file naming at some point to avoid collisions better. TSC has a withTemporaryFile utility for this, but I think it has the same problem as withTemporaryDirectory - it always uses the local file system. I'm fine with merging this as-is as long as @DougGregor doesn't have any remaining concerns!

@owenv owenv requested a review from DougGregor September 12, 2020 03:28
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thank you for picking it up again!

@cltnschlosser
Copy link
Contributor Author

Okay, merge when ready

@DougGregor DougGregor merged commit e9b27e8 into swiftlang:master Sep 12, 2020
@compnerd
Copy link
Member

This is breaking the swift-package-manager build :-(

compnerd added a commit to compnerd/swift-package-manager that referenced this pull request Sep 12, 2020
swiftlang/swift-driver#144 introduced a new case in the `VirtualPath` type,
resulting in the switch no longer being exhaustive.  Abort if this is
encountered until it can be handled properly.
@owenv
Copy link
Contributor

owenv commented Sep 12, 2020

Looks like a switch needs to be updated to support the new case added to VirtualPath:

/home/buildnode/jenkins/workspace/oss-swift-incremental-RA-linux-ubuntu-16_04/swiftpm/Sources/Build/ManifestBuilder.swift:855:9: error: switch must be exhaustive
10:12:41         switch file {
10:12:41         ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants