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

Charts framework takes a long time to build #5123

Open
drewster99 opened this issue Nov 8, 2023 · 0 comments
Open

Charts framework takes a long time to build #5123

drewster99 opened this issue Nov 8, 2023 · 0 comments
Assignees

Comments

@drewster99
Copy link

drewster99 commented Nov 8, 2023

What did you do?

ℹ Clean Xcode derived data, open Charts.xcworkspace, hit Command-B to build

What did you expect to happen?

ℹ Build should be quick.

What happened instead?

ℹ Takes almost 20 seconds on M1 Max macbook pro (Sonoma 14.1.1, Xcode 15.0.1)

DGCharts Environment

DGCharts version/Branch/Commit Number: 5.0.0 / master / e516b04
Xcode version: 15.0.1
Swift version: 5.9
Platform(s) running DGCharts: iOS, macOS
macOS version running Xcode: Sonoma 14.1.1

Demo Project

ℹ Using just the macOS demo project that's included in the Charts.xcworkspace.

Details

Looking into this further, the Xcode build timeline shows all the Swift files that are part of the DGCharts framework being compiled sequentially. This is due to Compilation Mode being set to Whole Module (rather than Incremental) for Debug builds:

Xcode build timeline

Adding -Xfrontend -warn-long-expression-type-checking=50 to OTHER_SWIFT_FLAGS, which causes the Swift compiler to emit warnings for expressions that take longer than 50ms to type-check, we do see some warnings that indicate Swift is taking a long time to type check some expressions:

image

These are all in ChartAnimationEasing.swift. The worst are these offenders:

image image image

Looking at the other build settings:

  • Eager Linking should generally be enabled (Yes) to support better parallelization during builds (see WWDC 2022 video: https://developer.apple.com/videos/play/wwdc2022/110364/)
  • Enable Module Verifier should be No for Debug builds, as this gets in the way of parallelization during builds also.
  • Compilation Mode should be Incremental for Debug builds, but Whole Module for Release.

RECOMMENDATIONS

  1. Set Eager Linking build setting to Yes for Charts framework target
  2. Set Enable Module Verifier build setting to No for Debug builds
  3. Set Compilation Mode to Incremental for Debug builds
  4. Add -Xfrontend -warn-long-expression-type-checking=50 (or perhaps use 100) to OTHER_SWIFT_FLAGS so the Swift compiler will emit warnings for expressions that take a long time to type-check. The number after the = is the number of milliseconds threshold, above which warnings will be emitted.
  5. Refactor the slow type-checking hotspots identified above.
drewster99 pushed a commit to drewster99/Charts that referenced this issue Nov 8, 2023
Resolves issue ChartsOrg#5123 "Charts framework takes a long time to build" (ChartsOrg#5123) by implementing the recommendations listed at the end of the issue:
- Set `Eager Linking` build setting to `Yes` for `Charts` framework target
- Set `Enable Module Verifier` build setting to `No` for `Debug` builds
- Set `Compilation Mode` to `Incremental` for `Debug` builds
- Add `-Xfrontend -warn-long-expression-type-checking=50` (or perhaps use `100`) to `OTHER_SWIFT_FLAGS` so the Swift compiler will emit warnings for expressions that take a long time to type-check. The number after the = is the number of milliseconds threshold, above which warnings will be emitted.
- Refactored the slow type-checking hotspots identified above in `ChartAnimationEasing.swift`, breaking out expressions which are slow to type-check into separate, quicker-to-type-check expressions.
@pmairoldi pmairoldi self-assigned this Feb 16, 2024
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

No branches or pull requests

2 participants