Skip to content

Cache the default malloc zone #29978

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

Merged
merged 1 commit into from
Feb 21, 2020

Conversation

Catfish-Man
Copy link
Contributor

I measured a 7% win on FilterEvenUsingReduceInto with fast dealloc enabled (which it won't be in CI)

@Catfish-Man Catfish-Man requested a review from mikeash February 21, 2020 00:45
@Catfish-Man Catfish-Man self-assigned this Feb 21, 2020
@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
StringComparison_nonBMPSlowestPrenormal 1390 1580 +13.7% 0.88x
ObjectiveCBridgeStringHash 70 76 +8.6% 0.92x (?)
EqualSubstringSubstring 39 42 +7.7% 0.93x (?)
LessSubstringSubstring 39 42 +7.7% 0.93x (?)
EqualSubstringSubstringGenericEquatable 39 42 +7.7% 0.93x (?)
EqualSubstringString 39 42 +7.7% 0.93x
LessSubstringSubstringGenericComparable 39 42 +7.7% 0.93x (?)

Code size: -O

Performance: -Osize

Regression OLD NEW DELTA RATIO
FlattenListFlatMap 5903 8048 +36.3% 0.73x (?)
FlattenListLoop 4452 5282 +18.6% 0.84x (?)
StringComparison_nonBMPSlowestPrenormal 1420 1570 +10.6% 0.90x (?)
EqualStringSubstring 40 44 +10.0% 0.91x
ObjectiveCBridgeStringHash 70 76 +8.6% 0.92x (?)
EqualSubstringString 39 42 +7.7% 0.93x
 
Improvement OLD NEW DELTA RATIO
ObjectiveCBridgeStubFromNSDateRef 4270 3800 -11.0% 1.12x (?)
ObjectiveCBridgeStubFromArrayOfNSString2 3560 3310 -7.0% 1.08x (?)

Code size: -Osize

Performance: -Onone

Regression OLD NEW DELTA RATIO
ObjectiveCBridgeStringHash 70 76 +8.6% 0.92x (?)
EqualStringSubstring 47 51 +8.5% 0.92x (?)
DictionaryBridgeToObjC_Access 969 1045 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
StringBuilderWithLongSubstring 3200 2850 -10.9% 1.12x (?)
Breadcrumbs.CopyUTF16CodeUnits.ASCII 194 174 -10.3% 1.11x (?)
DictionaryOfAnyHashableStrings_lookup 5400 4968 -8.0% 1.09x (?)
ArrayOfPOD 1113 1033 -7.2% 1.08x (?)

Code size: -swiftlibs

How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@Catfish-Man
Copy link
Contributor Author

Looks like with fast dealloc disabled the win is below the 7% threshold to be reported, so we just get noise.

Disturbing to see (?) on a 36% change though.

@Catfish-Man Catfish-Man merged commit 428a08d into swiftlang:master Feb 21, 2020
@@ -57,6 +61,13 @@ using namespace swift;
static_assert(_swift_MinAllocationAlignment > MALLOC_ALIGN_MASK,
"Swift's default alignment must exceed platform malloc mask.");

#if defined(__APPLE__)
static inline malloc_zone_t *DEFAULT_ZONE() {
static malloc_zone_t *z = SWIFT_LAZY_CONSTANT(malloc_default_zone());
Copy link
Contributor

Choose a reason for hiding this comment

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

The static and SWIFT_LAZY_CONSTANT create two levels of lazy initialization; we only need one of them IIUC.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! This shouldn't have the static.

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.

4 participants