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

Drastically Improve Speed and Memory Performance #253

Merged
merged 8 commits into from
Feb 25, 2024

Conversation

cpisciotta
Copy link
Owner

@cpisciotta cpisciotta commented Feb 25, 2024

Changes

Drastically improve xcbeautify's performance (time and memory). Testing with a large xcodebuild log, this change dropped xcbeautify's execution time by ~90% and memory footprint by ~99%.

  • Reduce unnecessary type instantiations, namely NSRegularExpression.
  • Skip parsing empty lines.
  • Introduce time-tracking logic and large xcodebuild log test to (1) find and fix the existing issue and (2) prevent future performance regressions.

Testing

Average results after formatting large_xcodebuild_log.txt (99.9 MB xcodebuild log).

Measurement Before After Absolute Difference Percentage Difference
Memory 2.21 GB 8.3 MB -2254.74 MB / -2.2 GB -99.63%
Time 66 seconds 5.9 seconds -60.1 seconds -91%

Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 89.47368% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 84.94%. Comparing base (092bb2d) to head (cbc94b2).

Files Patch % Lines
Sources/XcbeautifyLib/Parser.swift 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #253      +/-   ##
==========================================
- Coverage   85.76%   84.94%   -0.82%     
==========================================
  Files          14       14              
  Lines        1545     1461      -84     
==========================================
- Hits         1325     1241      -84     
  Misses        220      220              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cpisciotta cpisciotta mentioned this pull request Feb 25, 2024
This was linked to issues Feb 25, 2024
@cpisciotta cpisciotta marked this pull request as ready for review February 25, 2024 18:43
@cpisciotta cpisciotta merged commit 168a632 into main Feb 25, 2024
7 checks passed
@cpisciotta cpisciotta deleted the charles/memory-improvements branch February 25, 2024 18:51
cpisciotta added a commit that referenced this pull request Feb 25, 2024
- Consolidate `captureGroups` logic into `Regex`
  - Constrain `pattern`
  - Drastically reduce instantiations of `NSRegularExpression`
- Exit early on empty lines
- Mark `Regex` as `final`
- Add `large_xcodebuild_log` test to (1) identify the bottleneck and (2)
prevent a future bottleneck
- Add time tracking to `run`
- Move `CaptureGroup.Type` array into static property

See testing results [here](#253).
cpisciotta added a commit that referenced this pull request Feb 25, 2024
## Changes

Drastically improve xcbeautify's performance (time and memory). Testing with a large xcodebuild log, this change dropped xcbeautify's execution time by ~90% and memory footprint by ~99%.

- Reduce unnecessary type instantiations, namely NSRegularExpression.
- Skip parsing empty lines.
- Introduce time-tracking logic and large xcodebuild log test to (1) find and fix the existing issue and (2) prevent future performance regressions.

## Testing

See testing results [here](#253).
cpisciotta added a commit that referenced this pull request Feb 25, 2024
Drastically improve xcbeautify's performance (time and memory). Testing with a large xcodebuild log, this change dropped xcbeautify's execution time by ~90% and memory footprint by ~99%.

- Reduce unnecessary type instantiations, namely NSRegularExpression.
- Skip parsing empty lines.
- Introduce time-tracking logic and large xcodebuild log test to (1) find and fix the existing issue and (2) prevent future performance regressions.

See testing results [here](#253).
cpisciotta added a commit that referenced this pull request Feb 25, 2024
Drastically improve xcbeautify's performance (time and memory). Testing with a large xcodebuild log, this change dropped xcbeautify's execution time by ~90% and memory footprint by ~99%.

- Reduce unnecessary type instantiations, namely NSRegularExpression.
- Skip parsing empty lines.
- Introduce time-tracking logic and large xcodebuild log test to (1) find and fix the existing issue and (2) prevent future performance regressions.

See testing results [here](#253).
cpisciotta added a commit that referenced this pull request Feb 25, 2024
Drastically improve xcbeautify's performance (time and memory). Testing with a large xcodebuild log, this change dropped xcbeautify's execution time by ~90% and memory footprint by ~99%.

- Reduce unnecessary type instantiations, namely NSRegularExpression.
- Skip parsing empty lines.
- Introduce time-tracking logic and large xcodebuild log test to (1) find and fix the existing issue and (2) prevent future performance regressions.

See testing results [here](#253).
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.

Exit Early on Empty Lines Severe memory usage
1 participant