Skip to content

Conversation

@jmschonfeld
Copy link
Contributor

@jmschonfeld jmschonfeld commented Aug 8, 2024

This enables whole module optimization for FoundationEssentials and FoundationInternationalization for release builds. We've found that this added optimization results in a significant (up to 4x) performance improvement for JSONDecoder in our benchmarks:

----------------------------------------------------------------------------------------------------------------------------
Canada-decodeFromJSON metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│          Throughput (# / s) (K)          │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │       9 │       9 │       9 │       9 │       9 │       9 │       9 │      28 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                 main-wmo                 │      25 │      24 │      24 │      24 │      24 │      23 │      23 │      73 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │      16 │      15 │      15 │      15 │      15 │      14 │      14 │      45 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │     178 │     167 │     167 │     167 │     167 │     156 │     156 │      45 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------
Canada-encodeToJSON metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│          Throughput (# / s) (K)          │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │      11 │      11 │      11 │      11 │      10 │      10 │      10 │      32 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                 main-wmo                 │      14 │      14 │      14 │      14 │      14 │      13 │      13 │      42 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │       3 │       3 │       3 │       3 │       4 │       3 │       3 │      10 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      27 │      27 │      27 │      27 │      40 │      30 │      30 │      10 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------
Twitter-decodeFromJSON metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│          Throughput (# / s) (K)          │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │      67 │      65 │      64 │      62 │      61 │      58 │      58 │     190 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                 main-wmo                 │     336 │     334 │     334 │     334 │     333 │     247 │     240 │     982 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │     269 │     269 │     270 │     272 │     272 │     189 │     182 │     792 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │     401 │     414 │     422 │     439 │     446 │     326 │     314 │     792 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------
Twitter-encodeToJSON metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│          Throughput (# / s) (K)          │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │     301 │     289 │     286 │     278 │     251 │     220 │     202 │     830 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                 main-wmo                 │     379 │     369 │     366 │     360 │     356 │     278 │     267 │    1078 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │      78 │      80 │      80 │      82 │     105 │      58 │      65 │     248 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      26 │      28 │      28 │      29 │      42 │      26 │      32 │     248 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@glessard glessard left a comment

Choose a reason for hiding this comment

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

🏎️

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test Windows platform

@glessard
Copy link
Contributor

glessard commented Aug 9, 2024

The only test failure is this:

Test Case 'ProcessInfoTests.testProcessName' started at 2024-08-09 18:13:47.828

C:\source\swift-foundation\Tests\FoundationEssentialsTests\ProcessInfoTests.swift:181: error: ProcessInfoTests.testProcessName : XCTAssertEqual failed: ("C:\source\swift-foundation\.build\x86_64-unknown-windows-msvc\debug\swift-foundationPackageTests.xctest") is not equal to ("swift-foundationPackageTests.xctest") - 

...and is not related to this change.

@jmschonfeld
Copy link
Contributor Author

Yeah @iCharlesHu is fixing that with #839

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit 8f26c08 into swiftlang:main Aug 9, 2024
@jmschonfeld jmschonfeld deleted the wmo branch August 9, 2024 21:54
jmschonfeld added a commit to jmschonfeld/swift-foundation that referenced this pull request Aug 9, 2024
* Enable whole-module-optimization in release builds

* Address feedback

* Fix build failures

* Don't enable WMO on Windows
@jmschonfeld jmschonfeld mentioned this pull request Aug 9, 2024
jmschonfeld added a commit that referenced this pull request Aug 10, 2024
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
* Enable whole-module-optimization in release builds

* Address feedback

* Fix build failures

* Don't enable WMO on Windows
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.

3 participants