Indexing in Xcode is significantly slower when running on battery power
| Originator: | arkadiusz.holko | ||
| Number: | rdar://34652170 | Date Originated: | 26-Sep-2017 01:13 PM |
| Status: | Closed | Resolved: | |
| Product: | Developer Tools | Product Version: | 9.0 |
| Classification: | Performance | Reproducible: | Always |
Summary: I noticed that indexing phase was taking a long time in my project. I did a little investigation and noticed that it’s somehow throttled when my MBP is not plugged in to power. Steps to Reproduce: 1. Clear derived data folder. 2. Open a non-trivial Swift project. 3. Start a stopwatch when “Indexing” label appears. 4. Stop a stopwatch when the indexing is done. Repeat steps 1-4 both when running on battery power and when plugged in to external power. Expected Results: Indexing should take the same amount of time no matter if a MacBook is plugged in or running on battery power. There’s a tradeoff between energy impact and performance but in this case I think the performance is more important. Actual Results: In my case the indexing takes on average: - 2:32m when my MBP is plugged in - 5:11m when my MBP is running on battery power Version: 9.0 Notes: -
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Response
This issue behaves as intended based on the following:
This is by design, we throttle background indexing down to one thread when on battery because we don’t want to drain the battery of the laptop, particularly in case being on battery is a temporary state.
Note that with Xcode 9’s index-while-building we still get the data when building regardless of whether it is on battery or power, and performance of background indexing is less important since indexing data are provided via building the project.
Workaround
As a workaround, you can start the build instead of waiting for indexing to finish. Xcode 9 does indexing during compilation, per release notes:
"Updated the indexing engine to include the ability to index files as they are compiled."
Combined building and indexing takes 3:03m on the same machine.