Skip to content

Commit faa3d1d

Browse files
authored
Merge branch 'master' into nc_subscript_message
2 parents e32ad78 + 4986105 commit faa3d1d

File tree

720 files changed

+20853
-6264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

720 files changed

+20853
-6264
lines changed

apinotes/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ add_custom_target("copy_apinotes"
2828
COMMENT "Copying API notes to ${output_dir}"
2929
SOURCES "${sources}")
3030

31+
# This is treated as an OPTIONAL target because if we don't build the SDK
32+
# overlay, the files will be missing anyway. It also allows us to build
33+
# single overlays without installing the API notes.
3134
swift_install_in_component(sdk-overlay
32-
FILES ${sources}
33-
DESTINATION "lib/swift/apinotes")
35+
DIRECTORY "${output_dir}"
36+
DESTINATION "lib/swift/"
37+
OPTIONAL)

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ set(SWIFT_BENCH_MODULES
8989
single-source/FloatingPointPrinting
9090
single-source/Hanoi
9191
single-source/Hash
92-
single-source/HashQuadratic
9392
single-source/Histogram
9493
single-source/InsertCharacter
9594
single-source/Integrate

benchmark/Naming.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ benchmark is testing individual method on a concrete type.
2828
````
2929
⛔️ Dictionary2
3030
✅ AngryPhonebook
31-
✅ Dictionary.AnyHashable.String.update
3231
✅ Array.append.Array.Int
32+
✅ Dictionary.AnyHashable.String.update
3333
````
3434

3535
Benchmark names are used to run individual tests when passed as command line
@@ -42,8 +42,8 @@ optional chaining etc.
4242

4343
````
4444
✅ Array.append.Array.Int?
45-
✅ Flatten.Array.Tuple4.for-in.reserved
4645
✅ Bridging.NSArray.as!.Array.NSString
46+
✅ Flatten.Array.Tuple4.for-in.Reserve
4747
````
4848

4949
Note: Special characters that could be interpreted by the shell require escaping

benchmark/scripts/Benchmark_Driver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class BenchmarkDriver(object):
200200
with open(log_file, 'w') as f:
201201
f.write(output)
202202

203-
RESULT = '{:>3} {:<25} {:>7} {:>7} {:>6} {:>10} {:>6} {:>7} {:>10}'
203+
RESULT = '{:>3} {:<40} {:>7} {:>7} {:>6} {:>10} {:>6} {:>7} {:>10}'
204204

205205
def run_and_log(self, csv_console=True):
206206
"""Run benchmarks and continuously log results to the console.

benchmark/scripts/compare_perf_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ def _reset(self):
363363
# Parse lines like this
364364
# #,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)
365365
results_re = re.compile(
366-
r'( *\d+[, \t]+[\w.]+[, \t]+' + # #,TEST
367-
r'[, \t]+'.join([r'\d+'] * 2) + # at least 2...
368-
r'(?:[, \t]+\d*)*)') # ...or more numeric columns
366+
r'( *\d+[, \t]+[\w.\-\?!]+[, \t]+' + # #,TEST
367+
r'[, \t]+'.join([r'\d+'] * 2) + # at least 2...
368+
r'(?:[, \t]+\d*)*)') # ...or more numeric columns
369369

370370
def _append_result(self, result):
371371
columns = result.split(',') if ',' in result else result.split()

benchmark/scripts/run_smoke_bench

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
185185
tests = TestComparator(results[0], results[1], threshold)
186186
changed = tests.decreased + tests.increased
187187

188-
while len(changed) > 0 and unchanged_length_count < 5:
188+
while len(changed) > 0 and unchanged_length_count < 10:
189189
i += 1
190190
if VERBOSE:
191191
log(' test again: ' + str([test.name for test in changed]))

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,10 @@ def mock_run(test):
366366
self.assertEqual(log, header + csv_log)
367367
self.assertEqual(
368368
out.getvalue(),
369-
' # TEST SAMPLES MIN(μs) Q1(μs)' +
370-
' MEDIAN(μs) Q3(μs) MAX(μs) MAX_RSS(B)\n' +
371-
' 3 b1 5 101 102' +
372-
' 103 104 105 888\n' +
369+
' # TEST SAMPLES MIN(μs)' +
370+
' Q1(μs) MEDIAN(μs) Q3(μs) MAX(μs) MAX_RSS(B)\n' +
371+
' 3 b1 5 101' +
372+
' 102 103 104 105 888\n' +
373373
'\n' +
374374
'Total performance tests executed: 1\n')
375375

benchmark/scripts/test_compare_perf_tests.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,20 @@ class TestLogParser(unittest.TestCase):
445445
def test_parse_results_csv(self):
446446
"""Ignores uknown lines, extracts data from supported formats."""
447447
log = """#,TEST,SAMPLES,MIN(us),MAX(us),MEAN(us),SD(us),MEDIAN(us)
448-
34,BitCount,20,3,4,4,0,4
448+
7,Array.append.Array.Int?,20,10,10,10,0,10
449+
21,Bridging.NSArray.as!.Array.NSString,20,11,11,11,0,11
450+
42,Flatten.Array.Tuple4.lazy.for-in.Reserve,20,3,4,4,0,4
449451
450452
Total performance tests executed: 1
451453
"""
452454
parser = LogParser()
453455
results = parser.parse_results(log.splitlines())
454456
self.assertTrue(isinstance(results[0], PerformanceTestResult))
455-
self.assertEqual(results[0].name, 'BitCount')
457+
self.assertEquals(results[0].name, 'Array.append.Array.Int?')
458+
self.assertEquals(results[1].name,
459+
'Bridging.NSArray.as!.Array.NSString')
460+
self.assertEquals(results[2].name,
461+
'Flatten.Array.Tuple4.lazy.for-in.Reserve')
456462

457463
def test_parse_results_tab_delimited(self):
458464
log = '34\tBitCount\t20\t3\t4\t4\t0\t4'

benchmark/single-source/ArrayInClass.swift

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import TestsUtils
14-
public let ArrayInClass = BenchmarkInfo(
15-
name: "ArrayInClass",
16-
runFunction: run_ArrayInClass,
17-
tags: [.validation, .api, .Array],
18-
setUpFunction: { ac = ArrayContainer() },
19-
tearDownFunction: { ac = nil })
14+
public let ArrayInClass = [
15+
BenchmarkInfo(
16+
name: "ArrayInClass",
17+
runFunction: run_ArrayInClass,
18+
tags: [.validation, .api, .Array],
19+
setUpFunction: { ac = ArrayContainer() },
20+
tearDownFunction: { ac = nil }),
21+
BenchmarkInfo(name: "DistinctClassFieldAccesses",
22+
runFunction: run_DistinctClassFieldAccesses,
23+
tags: [.unstable, .api, .Array],
24+
setUpFunction: { workload = ClassWithArrs(N: 100_000) },
25+
tearDownFunction: { workload = nil }),
26+
]
2027

2128
var ac: ArrayContainer!
2229

@@ -41,3 +48,38 @@ public func run_ArrayInClass(_ N: Int) {
4148
let a = ac!
4249
a.runLoop(N)
4350
}
51+
52+
class ClassWithArrs {
53+
var N: Int = 0
54+
var A: [Int]
55+
var B: [Int]
56+
57+
init(N: Int) {
58+
self.N = N
59+
60+
A = [Int](repeating: 0, count: N)
61+
B = [Int](repeating: 0, count: N)
62+
}
63+
64+
func readArr() {
65+
for i in 0..<self.N {
66+
guard A[i] == B[i] else { fatalError("") }
67+
}
68+
}
69+
70+
func writeArr() {
71+
for i in 0..<self.N {
72+
A[i] = i
73+
B[i] = i
74+
}
75+
}
76+
}
77+
78+
var workload: ClassWithArrs!
79+
80+
public func run_DistinctClassFieldAccesses(_ N: Int) {
81+
for _ in 1...N {
82+
workload.writeArr()
83+
workload.readArr()
84+
}
85+
}

benchmark/single-source/ArrayLiteral.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import TestsUtils
1717

1818
public let ArrayLiteral = [
19-
BenchmarkInfo(name: "ArrayLiteral", runFunction: run_ArrayLiteral, tags: [.validation, .api, .Array]),
19+
BenchmarkInfo(name: "ArrayLiteral2", runFunction: run_ArrayLiteral, tags: [.validation, .api, .Array]),
2020
BenchmarkInfo(name: "ArrayValueProp", runFunction: run_ArrayValueProp, tags: [.validation, .api, .Array]),
2121
BenchmarkInfo(name: "ArrayValueProp2", runFunction: run_ArrayValueProp2, tags: [.validation, .api, .Array]),
2222
BenchmarkInfo(name: "ArrayValueProp3", runFunction: run_ArrayValueProp3, tags: [.validation, .api, .Array]),
@@ -31,7 +31,7 @@ func makeArray() -> [Int] {
3131
@inline(never)
3232
public func run_ArrayLiteral(_ N: Int) {
3333
for _ in 1...10000*N {
34-
_ = makeArray()
34+
blackHole(makeArray())
3535
}
3636
}
3737

0 commit comments

Comments
 (0)