Skip to content
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

Add a flag to parse serially #1063

Merged
merged 4 commits into from
May 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sourcery/Sourcery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class Sourcery {
// content annotated with file annotations per file path to write it to
fileprivate var fileAnnotatedContent: [Path: [String]] = [:]

private (set) var numberOfFilesThatHadToBeParsed: Int32 = 0
private (set) var numberOfFilesThatHadToBeParsed = 0
func incrementFileParsedCount() {
OSAtomicIncrement32(&numberOfFilesThatHadToBeParsed)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When I ran TSAN on the codebase this increment was causing some violations to be printed, and they went away when I switched to a DispatchQueue.sync as a barrier. However even with that change I still encountered the crashes.

Copy link
Owner

Choose a reason for hiding this comment

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

oh that's really interesting, would not expect that for sure

numberOfFilesThatHadToBeParsed += 1
}

/// Creates Sourcery processor
Expand Down Expand Up @@ -309,7 +309,7 @@ extension Sourcery {
numberOfFilesThatHadToBeParsed = 0

var lastError: Swift.Error?
let results = parserGenerator.parallelCompactMap { parser -> FileParserResult? in
let results = parserGenerator.compactMap { parser -> FileParserResult? in
do {
return try self.loadOrParse(parser: parser, cachesPath: cachesDir(sourcePath: from))
} catch {
Expand Down