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

Migrate LinterCache to use Codable models #2799

Merged
merged 5 commits into from
Jul 7, 2019

Conversation

jpsim
Copy link
Collaborator

@jpsim jpsim commented Jul 6, 2019

Improving performance and type safety. This changes the cache file format from JSON to binary plist when available, which also happens to reduce disk usage by around ~10% in my tests.

For a project with about 7k Swift files amounting to about ~500k lines of Swift code, here are the benchmarks for before and after:

$ hyperfine 'swiftlint-master lint --quiet' 'swiftlint-codable-cache lint --quiet'                    
Benchmark #1: swiftlint-master lint --quiet
  Time (mean ± σ):      3.500 s ±  0.037 s    [User: 5.208 s, System: 1.115 s]
  Range (min … max):    3.439 s …  3.573 s    10 runs
 
Benchmark #2: swiftlint-codable-cache lint --quiet
  Time (mean ± σ):      3.013 s ±  0.026 s    [User: 4.807 s, System: 1.117 s]
  Range (min … max):    2.966 s …  3.041 s    10 runs
 
Summary
  'swiftlint-codable-cache lint --quiet' ran
    1.16 ± 0.02 times faster than 'swiftlint-master lint --quiet'

jpsim added 2 commits July 6, 2019 15:30
improving performance and type safety
@jpsim jpsim requested review from marcelofabri and Jeehut July 6, 2019 22:55
jpsim added 2 commits July 6, 2019 15:57
For example if the file doesn't exist or can't be read.
@SwiftLintBot
Copy link

SwiftLintBot commented Jul 7, 2019

12 Messages
📖 Linting Aerial with this PR took 2.76s vs 2.76s on master (0% slower)
📖 Linting Alamofire with this PR took 5.3s vs 5.33s on master (0% faster)
📖 Linting Firefox with this PR took 13.65s vs 13.71s on master (0% faster)
📖 Linting Kickstarter with this PR took 24.33s vs 24.3s on master (0% slower)
📖 Linting Moya with this PR took 2.35s vs 2.63s on master (10% faster)
📖 Linting Nimble with this PR took 2.21s vs 2.29s on master (3% faster)
📖 Linting Quick with this PR took 0.81s vs 0.83s on master (2% faster)
📖 Linting Realm with this PR took 3.94s vs 3.98s on master (1% faster)
📖 Linting SourceKitten with this PR took 1.56s vs 1.53s on master (1% slower)
📖 Linting Sourcery with this PR took 4.91s vs 4.93s on master (0% faster)
📖 Linting Swift with this PR took 37.37s vs 37.36s on master (0% slower)
📖 Linting WordPress with this PR took 30.37s vs 30.31s on master (0% slower)

Generated by 🚫 Danger

@@ -1,12 +1,33 @@
import Foundation

internal enum LinterCacheError: Error {
private enum LinterCacheError: Error {
case invalidFormat
Copy link
Collaborator

Choose a reason for hiding this comment

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

this seems to be unused now

Copy link
Collaborator

@marcelofabri marcelofabri left a comment

Choose a reason for hiding this comment

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

👏

@jpsim jpsim merged commit 3a0c2b0 into master Jul 7, 2019
@jpsim jpsim deleted the migrate-lintercache-to-use-codable-models branch July 7, 2019 07:35
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.

None yet

3 participants