Skip to content

Add HashEncoder and QueryEngineTests #7435

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 14 commits into from
Apr 11, 2024
Merged

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Apr 2, 2024

Previously, QueryEngine couldn't cache anything due to a missing persistable hashing implementation that could be consistent across SwiftPM relaunches. Here HashEncoder is implemented on top Codable. While it probably has certain performance overhead when compared to an implementation with macros, it should be good enough for prototyping.

New QueryEngine now works for trivial computations, as verified by newly added QueryEngineTests.

This ports most of the current `GeneratorEngine` implementation from the Swift SDK Generator to the SwiftPM code base: https://github.com/apple/swift-sdk-generator/blob/main/Sources/GeneratorEngine/Engine.swift. Since Swift NIO is not supported on Windows, references to `AsyncHTTPClient` have been removed. Additionally, we can't use macros in the SwiftPM code base either, thus the `Query` protocol has to conform to `Encodable` instead. We don't have a consistent hashing implementation for `Encodable` yet, and a temporary stub for it is marked with `fatalError` for now.
Previously, `QueryEngine` couldn't cache anything due to a missing hashing implementation that could be consistent across SwiftPM relaunches. Here `HashEncoder` is implemented on top `Codable`. While it probably has certain performance overhead when compared to an implementation with macros, it should be good enough for prototyping.

New `QueryEngine` now works for trivial computations, as verified by newly added `QueryEngineTests`.
…xd/query-engine-scaffolding

# Conflicts:
#	Package.swift
…t-package-manager into maxd/query-engine-hashing

# Conflicts:
#	Package.swift
@MaxDesiatov MaxDesiatov added test suite improvements to SwiftPM test suite no functional change No user-visible functional changes included labels Apr 2, 2024
public let observabilityScope: ObservabilityScope
package let fileSystem: any AsyncFileSystem
package let httpClient = HTTPClient()
package let observabilityScope: ObservabilityScope
private let resultsCache: SQLiteBackedCache<FileCacheRecord>
private var isShutDown = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to handle circular query dependencies here, probably with a dictionary from Query to query result continuation.

Copy link
Contributor Author

@MaxDesiatov MaxDesiatov Apr 10, 2024

Choose a reason for hiding this comment

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

Also, don't recompute Query hash for deep FS trees.

Base automatically changed from maxd/query-engine-scaffolding to main April 10, 2024 17:40
…xd/query-engine-hashing

# Conflicts:
#	Package.swift
#	Sources/Basics/SQLiteBackedCache.swift
#	Sources/QueryEngine/FileSystem/AsyncFileSystem.swift
#	Sources/QueryEngine/FileSystem/OpenReadableFile.swift
#	Sources/QueryEngine/FileSystem/OpenWritableFile.swift
#	Sources/QueryEngine/FileSystem/VirtualFileSystem.swift
#	Sources/QueryEngine/Query.swift
#	Sources/QueryEngine/QueryEngine.swift
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) April 10, 2024 20:08
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows
@swift-ci test windows

@MaxDesiatov MaxDesiatov merged commit e79066a into main Apr 11, 2024
5 checks passed
@MaxDesiatov MaxDesiatov deleted the maxd/query-engine-hashing branch April 11, 2024 00:33
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
Depends on swiftlang#7347.

Previously, `QueryEngine` couldn't cache anything due to a missing
hashing implementation that could be consistent across SwiftPM
relaunches. Here `HashEncoder` is implemented on top `Codable`. While it
probably has certain performance overhead when compared to an
implementation with macros, it should be good enough for prototyping.

New `QueryEngine` now works for trivial computations, as verified by
newly added `QueryEngineTests`.
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
Depends on swiftlang#7347.

Previously, `QueryEngine` couldn't cache anything due to a missing
hashing implementation that could be consistent across SwiftPM
relaunches. Here `HashEncoder` is implemented on top `Codable`. While it
probably has certain performance overhead when compared to an
implementation with macros, it should be good enough for prototyping.

New `QueryEngine` now works for trivial computations, as verified by
newly added `QueryEngineTests`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no functional change No user-visible functional changes included test suite improvements to SwiftPM test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants