BPLATFORM(IOS) always evaluates to false
[WebKit-https.git] / Source / bmalloc / ChangeLog
1 2014-08-12  Daniel Bates  <dabates@apple.com>
2
3         BPLATFORM(IOS) always evaluates to false
4         https://bugs.webkit.org/show_bug.cgi?id=135843
5
6         Reviewed by Geoffrey Garen.
7
8         Fix typo in definition of BPLATFORM() and include system header TargetConditionals.h
9         (when building on an Apple platform) so that BPLATFORM(X) evaluates to true when
10         building for platform X. In particular, so that BPLATFORM(IOS) evaluates to true when
11         building for iOS.
12
13         As a side effect of this change, the change made in <http://trac.webkit.org/changeset/167289>
14         will be honored and iOS will assume a VM page size of 16kB (again) instead of 4kB.
15
16         * bmalloc/BPlatform.h:
17
18 2014-08-11  Andy Estes  <aestes@apple.com>
19
20         [iOS] Get rid of iOS.xcconfig
21         https://bugs.webkit.org/show_bug.cgi?id=135809
22
23         Reviewed by Joseph Pecoraro.
24
25         All iOS.xcconfig did was include AspenFamily.xcconfig, so there's no need for the indirection.
26
27         * Configurations/Base.xcconfig:
28         * Configurations/iOS.xcconfig: Removed.
29         * bmalloc.xcodeproj/project.pbxproj:
30
31 2014-05-01  Dan Bernstein  <mitz@apple.com>
32
33         Fixed production builds for the iOS Simulator.
34         <rdar://problem/16792221>
35
36         * Configurations/bmalloc.xcconfig: Include INSTALL_PATH_PREFIX in
37         PRIVATE_HEADERS_FOLDER_PATH when installing.
38
39 2014-04-20  Geoffrey Garen  <ggaren@apple.com>
40
41         bmalloc: Segregate pages by objects size
42         https://bugs.webkit.org/show_bug.cgi?id=131909
43
44         Reviewed by Andreas Kling.
45
46         2% reduction in memory-at-end on the Membuster memory_warning benchmarks.
47
48         * bmalloc/Allocator.cpp:
49         (bmalloc::Allocator::allocateSlowCase):
50         * bmalloc/Allocator.h:
51         (bmalloc::Allocator::allocateFastCase):
52         (bmalloc::Allocator::smallAllocatorFor): Use the new shared helper
53         function for size class calculation.
54
55         * bmalloc/Deallocator.cpp:
56         (bmalloc::Deallocator::Deallocator):
57         (bmalloc::Deallocator::scavenge):
58         (bmalloc::Deallocator::deallocateSmallLine):
59         (bmalloc::Deallocator::allocateSmallLine):
60         * bmalloc/Deallocator.h: Keep a cache for every size class, since the
61         cache can't be shared anymore.
62
63         * bmalloc/Heap.cpp:
64         (bmalloc::Heap::allocateSmallLineSlowCase):
65         * bmalloc/Heap.h:
66         (bmalloc::Heap::deallocateSmallLine): Ditto.
67
68         (bmalloc::Heap::allocateSmallLine): Check size class in addition to
69         page refcount when allocating a line because we might have deallocated
70         the page and the recycled it for another size class.
71
72         (bmalloc::Heap::deallocateMediumLine):
73         (bmalloc::Heap::allocateMediumLine):
74         * bmalloc/Line.h:
75         (bmalloc::Line::refCount):
76         * bmalloc/Page.h:
77         (bmalloc::Page::refCount):
78         (bmalloc::Page::smallSizeClass):
79         (bmalloc::Page::setSmallSizeClass):
80         (bmalloc::Page<Traits>::refCount): Deleted.
81         * bmalloc/Sizes.h:
82         (bmalloc::Sizes::smallSizeClassFor): New shared API for computing
83         an index into an array from a size.
84
85 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
86
87         bmalloc: Improved alignment in LargeChunk
88         https://bugs.webkit.org/show_bug.cgi?id=131895
89
90         Reviewed by Andreas Kling.
91
92         * bmalloc/Chunk.h:
93         * bmalloc/LargeChunk.h: Align to vmPageSize just like Chunk does.
94         Technically, the previous alignment was harmless, but I would prefer,
95         dear reader, not to have to explain the interlocking set of
96         circumstances that made it so.
97
98 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
99
100         Rolled out r167502 because it caused a crash on the facebook benchmark.
101
102         Unreviewed.
103
104             bmalloc: Added an XSmall line size
105             https://bugs.webkit.org/show_bug.cgi?id=131851
106
107             Reviewed by Sam Weinig.
108
109 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
110
111         bmalloc: Mutex should be harder to use wrong
112         https://bugs.webkit.org/show_bug.cgi?id=131879
113
114         Reviewed by Andreas Kling.
115
116         Mutex now has a proper constructor, so you can't deadlock by forgetting
117         to initialize it.
118
119         * bmalloc.xcodeproj/project.pbxproj:
120         * bmalloc/Allocator.cpp:
121         (bmalloc::Allocator::processXSmallAllocatorLog):
122         (bmalloc::Allocator::processSmallAllocatorLog):
123         (bmalloc::Allocator::processMediumAllocatorLog):
124         (bmalloc::Allocator::allocateLarge):
125         (bmalloc::Allocator::allocateXLarge): Global replace Mutex => StaticMutex,
126         since the Heap mutex is a static.
127
128         * bmalloc/AsyncTask.h:
129         (bmalloc::Function>::AsyncTask): Use Mutex, since we're not static. No
130         need for explicit initialization anymore.
131
132         * bmalloc/Deallocator.cpp:
133         (bmalloc::Deallocator::scavenge):
134         (bmalloc::Deallocator::deallocateLarge):
135         (bmalloc::Deallocator::deallocateXLarge):
136         (bmalloc::Deallocator::processObjectLog):
137         (bmalloc::Deallocator::deallocateSmallLine):
138         (bmalloc::Deallocator::deallocateXSmallLine):
139         (bmalloc::Deallocator::allocateSmallLine):
140         (bmalloc::Deallocator::allocateXSmallLine):
141         (bmalloc::Deallocator::deallocateMediumLine):
142         (bmalloc::Deallocator::allocateMediumLine):
143         * bmalloc/Deallocator.h:
144         * bmalloc/Heap.cpp:
145         (bmalloc::sleep):
146         (bmalloc::Heap::Heap):
147         (bmalloc::Heap::concurrentScavenge):
148         (bmalloc::Heap::scavenge):
149         (bmalloc::Heap::scavengeSmallPages):
150         (bmalloc::Heap::scavengeXSmallPages):
151         (bmalloc::Heap::scavengeMediumPages):
152         (bmalloc::Heap::scavengeLargeRanges):
153         (bmalloc::Heap::allocateXSmallLineSlowCase):
154         (bmalloc::Heap::allocateSmallLineSlowCase):
155         (bmalloc::Heap::allocateMediumLineSlowCase):
156         (bmalloc::Heap::allocateXLarge):
157         (bmalloc::Heap::deallocateXLarge):
158         (bmalloc::Heap::allocateLarge):
159         (bmalloc::Heap::deallocateLarge):
160         * bmalloc/Heap.h:
161         (bmalloc::Heap::deallocateXSmallLine):
162         (bmalloc::Heap::allocateXSmallLine):
163         (bmalloc::Heap::deallocateSmallLine):
164         (bmalloc::Heap::allocateSmallLine):
165         (bmalloc::Heap::deallocateMediumLine):
166         (bmalloc::Heap::allocateMediumLine):
167         * bmalloc/Line.h:
168         (bmalloc::Line<Traits>::deref):
169         * bmalloc/Mutex.cpp: Removed.
170         * bmalloc/Mutex.h:
171         (bmalloc::Mutex::Mutex):
172         (bmalloc::Mutex::init): Deleted.
173         (bmalloc::Mutex::try_lock): Deleted.
174         (bmalloc::Mutex::lock): Deleted.
175         (bmalloc::Mutex::unlock): Deleted.
176         * bmalloc/Page.h:
177         (bmalloc::Page<Traits>::ref):
178         (bmalloc::Page<Traits>::deref):
179         (bmalloc::Page<Traits>::refCount):
180         * bmalloc/PerProcess.h:
181         (bmalloc::PerProcess::mutex):
182         (bmalloc::PerProcess<T>::getSlowCase):
183         * bmalloc/StaticMutex.cpp: Added.
184         (bmalloc::StaticMutex::lockSlowCase):
185         * bmalloc/StaticMutex.h: Added.
186         (bmalloc::StaticMutex::init):
187         (bmalloc::StaticMutex::try_lock):
188         (bmalloc::StaticMutex::lock):
189         (bmalloc::StaticMutex::unlock):
190         * bmalloc/VMHeap.h:
191         (bmalloc::VMHeap::deallocateXSmallPage):
192         (bmalloc::VMHeap::deallocateSmallPage):
193         (bmalloc::VMHeap::deallocateMediumPage):
194         (bmalloc::VMHeap::deallocateLargeRange):
195         * bmalloc/bmalloc.h:
196         (bmalloc::api::scavenge): Global replace Mutex => StaticMutex,
197         since the Heap mutex is a static.
198
199 2014-04-18  Geoffrey Garen  <ggaren@apple.com>
200
201         bmalloc: AsyncTask should use Mutex instead of std::mutex
202         https://bugs.webkit.org/show_bug.cgi?id=131865
203
204         Reviewed by Gavin Barraclough.
205
206         std::mutex is so slow that it makes parallelizing simple tasks through
207         AsyncTask a net regression. Mutex fixes this.
208
209         * bmalloc/AsyncTask.h:
210         (bmalloc::Function>::AsyncTask):
211         (bmalloc::Function>::join):
212         (bmalloc::Function>::runSlowCase):
213         (bmalloc::Function>::entryPoint):
214         * bmalloc/Mutex.h:
215         (bmalloc::Mutex::init):
216
217 2014-04-18  Geoffrey Garen  <ggaren@apple.com>
218
219         bmalloc: Added an XSmall line size
220         https://bugs.webkit.org/show_bug.cgi?id=131851
221
222         Reviewed by Sam Weinig.
223
224         Reduces malloc footprint on Membuster recordings by 10%.
225
226         This is a throughput regression, but we're still way ahead of TCMalloc.
227         I have some ideas for how to recover the regression -- but I wanted to
228         get this win in first.
229
230         Full set of benchmark results:
231
232                 bmalloc> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks --measure-heap nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
233                                                                                                 
234                                                                nopatch                      patch                                Δ
235                 Peak Memory:
236                     reddit_memory_warning                      7,896kB                    7,532kB                  ^ 1.05x smaller
237                     flickr_memory_warning                     12,968kB                   12,324kB                  ^ 1.05x smaller
238                     theverge_memory_warning                   16,672kB                   15,200kB                   ^ 1.1x smaller
239
240                     <geometric mean>                          11,952kB                   11,216kB                  ^ 1.07x smaller
241                     <arithmetic mean>                         12,512kB                   11,685kB                  ^ 1.07x smaller
242                     <harmonic mean>                           11,375kB                   10,726kB                  ^ 1.06x smaller
243
244                 Memory at End:
245                     reddit_memory_warning                      7,320kB                    6,856kB                  ^ 1.07x smaller
246                     flickr_memory_warning                     10,848kB                    9,692kB                  ^ 1.12x smaller
247                     theverge_memory_warning                   16,380kB                   14,872kB                   ^ 1.1x smaller
248
249                     <geometric mean>                          10,916kB                    9,961kB                   ^ 1.1x smaller
250                     <arithmetic mean>                         11,516kB                   10,473kB                   ^ 1.1x smaller
251                     <harmonic mean>                           10,350kB                    9,485kB                  ^ 1.09x smaller
252
253                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
254                                                                                                 
255                                                    nopatch                patch                         Δ
256                 Execution Time:
257                     churn                            127ms                151ms            ! 1.19x slower
258                     list_allocate                    130ms                164ms            ! 1.26x slower
259                     tree_allocate                    109ms                127ms            ! 1.17x slower
260                     tree_churn                       115ms                120ms            ! 1.04x slower
261                     facebook                         240ms                259ms            ! 1.08x slower
262                     fragment                          91ms                131ms            ! 1.44x slower
263                     fragment_iterate                 105ms                106ms            ! 1.01x slower
264                     message_one                      260ms                259ms             ^ 1.0x faster
265                     message_many                     149ms                154ms            ! 1.03x slower
266                     medium                           194ms                248ms            ! 1.28x slower
267                     big                              157ms                160ms            ! 1.02x slower
268
269                     <geometric mean>                 144ms                163ms            ! 1.13x slower
270                     <arithmetic mean>                152ms                171ms            ! 1.12x slower
271                     <harmonic mean>                  137ms                156ms            ! 1.14x slower
272
273                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
274                                                                                                 
275                                                                        nopatch                          patch                                     Δ
276                 Execution Time:
277                     churn                                                126ms                          148ms                        ! 1.17x slower
278                     churn --parallel                                      62ms                           76ms                        ! 1.23x slower
279                     list_allocate                                        130ms                          164ms                        ! 1.26x slower
280                     list_allocate --parallel                             120ms                          175ms                        ! 1.46x slower
281                     tree_allocate                                        111ms                          127ms                        ! 1.14x slower
282                     tree_allocate --parallel                              95ms                          135ms                        ! 1.42x slower
283                     tree_churn                                           115ms                          124ms                        ! 1.08x slower
284                     tree_churn --parallel                                107ms                          126ms                        ! 1.18x slower
285                     facebook                                             240ms                          276ms                        ! 1.15x slower
286                     facebook --parallel                                  802ms                        1,088ms                        ! 1.36x slower
287                     fragment                                              92ms                          130ms                        ! 1.41x slower
288                     fragment --parallel                                   66ms                          124ms                        ! 1.88x slower
289                     fragment_iterate                                     109ms                          127ms                        ! 1.17x slower
290                     fragment_iterate --parallel                           55ms                           64ms                        ! 1.16x slower
291                     message_one                                          260ms                          260ms                                      
292                     message_many                                         170ms                          238ms                         ! 1.4x slower
293                     medium                                               185ms                          250ms                        ! 1.35x slower
294                     medium --parallel                                    210ms                          334ms                        ! 1.59x slower
295                     big                                                  150ms                          169ms                        ! 1.13x slower
296                     big --parallel                                       138ms                          144ms                        ! 1.04x slower
297
298                     <geometric mean>                                     135ms                          170ms                        ! 1.26x slower
299                     <arithmetic mean>                                    167ms                          214ms                        ! 1.28x slower
300                     <harmonic mean>                                      117ms                          148ms                        ! 1.26x slower
301
302                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks TC:~/scratch/Build-TCMalloc/Release/ patch:~/webkit/WebKitBuild/Release/
303
304                                                                     TC                      patch                                Δ
305                 Peak Memory:
306                     reddit_memory_warning                     13,836kB                   13,436kB                  ^ 1.03x smaller
307                     flickr_memory_warning                     24,868kB                   25,188kB                   ! 1.01x bigger
308                     theverge_memory_warning                   24,504kB                   26,636kB                   ! 1.09x bigger
309
310                     <geometric mean>                          20,353kB                   20,812kB                   ! 1.02x bigger
311                     <arithmetic mean>                         21,069kB                   21,753kB                   ! 1.03x bigger
312                     <harmonic mean>                           19,570kB                   19,780kB                   ! 1.01x bigger
313
314                 Memory at End:
315                     reddit_memory_warning                      8,656kB                   10,016kB                   ! 1.16x bigger
316                     flickr_memory_warning                     11,844kB                   13,784kB                   ! 1.16x bigger
317                     theverge_memory_warning                   18,516kB                   22,748kB                   ! 1.23x bigger
318
319                     <geometric mean>                          12,382kB                   14,644kB                   ! 1.18x bigger
320                     <arithmetic mean>                         13,005kB                   15,516kB                   ! 1.19x bigger
321                     <harmonic mean>                           11,813kB                   13,867kB                   ! 1.17x bigger
322
323                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks TC:~/scratch/Build-TCMalloc/Release/ patch:~/webkit/WebKitBuild/Release/
324                                                                                                 
325                                                         TC                patch                         Δ
326                 Execution Time:
327                     churn                            416ms                148ms            ^ 2.81x faster
328                     list_allocate                    463ms                164ms            ^ 2.82x faster
329                     tree_allocate                    292ms                127ms             ^ 2.3x faster
330                     tree_churn                       157ms                120ms            ^ 1.31x faster
331                     facebook                         327ms                276ms            ^ 1.18x faster
332                     fragment                         335ms                129ms             ^ 2.6x faster
333                     fragment_iterate                 344ms                108ms            ^ 3.19x faster
334                     message_one                      386ms                258ms             ^ 1.5x faster
335                     message_many                     410ms                154ms            ^ 2.66x faster
336                     medium                           391ms                245ms             ^ 1.6x faster
337                     big                              261ms                167ms            ^ 1.56x faster
338
339                     <geometric mean>                 332ms                164ms            ^ 2.02x faster
340                     <arithmetic mean>                344ms                172ms            ^ 1.99x faster
341                     <harmonic mean>                  317ms                157ms            ^ 2.02x faster
342
343         * bmalloc.xcodeproj/project.pbxproj:
344         * bmalloc/Allocator.cpp:
345         (bmalloc::Allocator::Allocator): Don't assume that each allocator's
346         index corresponds with its size. Instead, use the size selection function
347         explicitly. Now that we have XSmall, some small allocator entries are
348         unused.
349
350         (bmalloc::Allocator::scavenge):
351         (bmalloc::Allocator::log):
352         (bmalloc::Allocator::processXSmallAllocatorLog):
353         (bmalloc::Allocator::allocateSlowCase):
354         * bmalloc/Allocator.h:
355         (bmalloc::Allocator::xSmallAllocatorFor):
356         (bmalloc::Allocator::allocateFastCase):
357         * bmalloc/Chunk.h:
358         * bmalloc/Deallocator.cpp:
359         (bmalloc::Deallocator::scavenge):
360         (bmalloc::Deallocator::processObjectLog):
361         (bmalloc::Deallocator::deallocateSlowCase):
362         (bmalloc::Deallocator::deallocateXSmallLine):
363         (bmalloc::Deallocator::allocateXSmallLine):
364         * bmalloc/Deallocator.h:
365         (bmalloc::Deallocator::deallocateFastCase):
366         * bmalloc/Heap.cpp:
367         (bmalloc::Heap::scavenge):
368         (bmalloc::Heap::scavengeXSmallPages):
369         (bmalloc::Heap::allocateXSmallLineSlowCase):
370         * bmalloc/Heap.h:
371         (bmalloc::Heap::deallocateXSmallLine):
372         (bmalloc::Heap::allocateXSmallLine):
373         * bmalloc/LargeChunk.h:
374         (bmalloc::LargeChunk::get):
375         (bmalloc::LargeChunk::endTag):
376         * bmalloc/Line.h:
377         * bmalloc/MediumAllocator.h:
378         (bmalloc::MediumAllocator::allocate):
379         (bmalloc::MediumAllocator::refill):
380         * bmalloc/ObjectType.cpp:
381         (bmalloc::objectType):
382         * bmalloc/ObjectType.h:
383         (bmalloc::isXSmall):
384         (bmalloc::isSmall):
385         (bmalloc::isMedium):
386         (bmalloc::isLarge):
387         (bmalloc::isSmallOrMedium): Deleted.
388         * bmalloc/SegregatedFreeList.h: I boiler-plate copied existing code for
389         handling small objects. There's probably a reasonable way to share this
390         code in the future -- I'll look into that once it's stopped changing.
391
392         * bmalloc/Sizes.h: Tweaked size classes to make Membuster happy. This
393         is the main reason things got slower.
394
395         * bmalloc/SmallAllocator.h:
396         (bmalloc::SmallAllocator::allocate):
397         * bmalloc/SmallTraits.h:
398         * bmalloc/VMHeap.cpp:
399         (bmalloc::VMHeap::allocateXSmallChunk):
400         * bmalloc/VMHeap.h:
401         (bmalloc::VMHeap::allocateXSmallPage):
402         (bmalloc::VMHeap::deallocateXSmallPage):
403         * bmalloc/XSmallAllocator.h: Added.
404         (bmalloc::XSmallAllocator::isNull):
405         (bmalloc::XSmallAllocator::canAllocate):
406         (bmalloc::XSmallAllocator::XSmallAllocator):
407         (bmalloc::XSmallAllocator::line):
408         (bmalloc::XSmallAllocator::allocate):
409         (bmalloc::XSmallAllocator::objectCount):
410         (bmalloc::XSmallAllocator::derefCount):
411         (bmalloc::XSmallAllocator::refill):
412         * bmalloc/XSmallChunk.h: Added.
413         * bmalloc/XSmallLine.h: Added.
414         * bmalloc/XSmallPage.h: Added.
415         * bmalloc/XSmallTraits.h: Added.
416         * bmalloc/bmalloc.h:
417         (bmalloc::api::realloc): Boiler-plate copy, as above.
418
419 2014-04-14  Geoffrey Garen  <ggaren@apple.com>
420
421         MallocBench should scavenge explicitly instead of waiting
422         https://bugs.webkit.org/show_bug.cgi?id=131661
423
424         Reviewed by Andreas Kling.
425
426         Added explicit scavenge support to bmalloc. This isn't a memory win,
427         since bmalloc's per-thread cache is so small. But it makes testing
428         simpler.
429
430         * bmalloc/Allocator.cpp:
431         (bmalloc::Allocator::~Allocator):
432         (bmalloc::Allocator::scavenge):
433         * bmalloc/Allocator.h:
434         * bmalloc/Cache.cpp:
435         (bmalloc::Cache::operator new):
436         (bmalloc::Cache::operator delete):
437         (bmalloc::Cache::Cache):
438         (bmalloc::Cache::scavenge):
439         * bmalloc/Cache.h:
440         * bmalloc/Deallocator.cpp:
441         (bmalloc::Deallocator::~Deallocator):
442         (bmalloc::Deallocator::scavenge):
443         * bmalloc/Deallocator.h: Factored existing scavenging code into helper
444         functions, for reuse.
445
446         * bmalloc/Heap.cpp:
447         (bmalloc::sleep):
448         (bmalloc::Heap::concurrentScavenge):
449         (bmalloc::Heap::scavenge):
450         (bmalloc::Heap::scavengeSmallPages):
451         (bmalloc::Heap::scavengeMediumPages):
452         (bmalloc::Heap::scavengeLargeRanges):
453         * bmalloc/Heap.h: Made scavenge sleep duration a parameter. Forced
454         scavenging -- in response to a benchmark or a low memory warning --
455         wants to complete as soon as possible, so its sleep duration is 0.
456
457         * bmalloc/bmalloc.h:
458         (bmalloc::api::scavenge):
459         * bmalloc/mbmalloc.cpp: Exported the scavenge API for MallocBench's use.
460
461 2014-04-14  Geoffrey Garen  <ggaren@apple.com>
462
463         Use 4kB pages on Mac
464         https://bugs.webkit.org/show_bug.cgi?id=131658
465
466         Reviewed by Sam Weinig.
467
468         This reduces memory use a lot on Membuster:
469
470                                                                   base                      patch                                Δ
471                 Execution Time:
472                     reddit_memory_warning                         18ms                       17ms                   ^ 1.06x faster
473                     flickr_memory_warning                         34ms                       36ms                   ! 1.06x slower
474                     theverge_memory_warning                       39ms                       41ms                   ! 1.05x slower
475
476                     <geometric mean>                              29ms                       29ms                   ! 1.02x slower
477                     <arithmetic mean>                             30ms                       31ms                   ! 1.03x slower
478                     <harmonic mean>                               27ms                       27ms                    ^ 1.0x faster
479
480                 Peak Memory:
481                     reddit_memory_warning                     16,412kB                   16,436kB                    ! 1.0x bigger
482                     flickr_memory_warning                     30,120kB                   30,184kB                    ! 1.0x bigger
483                     theverge_memory_warning                   33,408kB                   33,420kB                    ! 1.0x bigger
484
485                     <geometric mean>                          25,466kB                   25,499kB                    ! 1.0x bigger
486                     <arithmetic mean>                         26,647kB                   26,680kB                    ! 1.0x bigger
487                     <harmonic mean>                           24,181kB                   24,214kB                    ! 1.0x bigger
488
489                 Memory at End:
490                     reddit_memory_warning                      2,404kB                    1,920kB                  ^ 1.25x smaller
491                     flickr_memory_warning                      3,764kB                    3,072kB                  ^ 1.23x smaller
492                     theverge_memory_warning                    3,648kB                    3,132kB                  ^ 1.16x smaller
493
494                     <geometric mean>                           3,208kB                    2,644kB                  ^ 1.21x smaller
495                     <arithmetic mean>                          3,272kB                    2,708kB                  ^ 1.21x smaller
496                     <harmonic mean>                            3,139kB                    2,574kB                  ^ 1.22x smaller
497
498
499         * bmalloc.xcodeproj/project.pbxproj:
500         * bmalloc/BPlatform.h: Added.
501         * bmalloc/VMAllocate.h: Only use 16kB pages on iOS because the page size
502         is 4kB on Mac.
503
504 2014-04-14  Alexey Proskuryakov  <ap@apple.com>
505
506         Fixed svn:ignore on bmalloc.xcodeproj, it had erroneous leading spaces.
507
508         * bmalloc.xcodeproj: Modified property svn:ignore.
509
510 2014-04-13  Geoffrey Garen  <ggaren@apple.com>
511
512         Fixed some mbmalloc exports
513         https://bugs.webkit.org/show_bug.cgi?id=131599
514
515         Reviewed by Ryosuke Niwa.
516
517         * bmalloc.xcodeproj/project.pbxproj: Made some headers a private part
518         of the project, so we can call them from API.
519
520         * bmalloc/mbmalloc.cpp: Marked the mbmalloc functions with default
521         visibility, so they show up as exported in the .dylib.
522
523 2014-04-09  Geoffrey Garen  <ggaren@apple.com>
524
525         Put bmalloc headers in the right place
526         https://bugs.webkit.org/show_bug.cgi?id=131464
527
528         Reviewed by Mark Rowe.
529
530         * Configurations/bmalloc.xcconfig: Set PRIVATE_HEADERS_FOLDER_PATH to
531         specify that we don't just want to dump all of our generically-named
532         headers into /usr/local/include.
533
534 2014-04-08  Geoffrey Garen  <ggaren@apple.com>
535
536         Made bmalloc more #include friendly
537         https://bugs.webkit.org/show_bug.cgi?id=131386
538
539         Reviewed by Andreas Kling.
540
541         Marked a bunch of headers private so they can be used from client code
542         that #includes bmalloc.h.
543
544         Renamed ASSERT macros to BASSERT. This matches their header, which already
545         had to be renamed, and fixes conflicts with WTF's ASSERT macros.
546
547         * bmalloc.xcodeproj/project.pbxproj:
548         * bmalloc/Allocator.cpp:
549         (bmalloc::Allocator::allocateSlowCase):
550         * bmalloc/AsyncTask.h:
551         (bmalloc::Function>::runSlowCase):
552         * bmalloc/BAssert.h:
553         * bmalloc/BoundaryTag.h:
554         (bmalloc::BoundaryTag::setSize):
555         * bmalloc/BoundaryTagInlines.h:
556         (bmalloc::validate):
557         (bmalloc::BoundaryTag::init):
558         (bmalloc::BoundaryTag::deallocate):
559         (bmalloc::BoundaryTag::splitLarge):
560         (bmalloc::BoundaryTag::allocate):
561         * bmalloc/Chunk.h:
562         * bmalloc/Deallocator.cpp:
563         (bmalloc::Deallocator::processObjectLog):
564         (bmalloc::Deallocator::deallocateSlowCase):
565         * bmalloc/Deallocator.h:
566         (bmalloc::Deallocator::deallocateFastCase):
567         * bmalloc/FixedVector.h:
568         (bmalloc::Capacity>::operator):
569         (bmalloc::Capacity>::push):
570         (bmalloc::Capacity>::pop):
571         (bmalloc::Capacity>::shrink):
572         * bmalloc/Heap.cpp:
573         (bmalloc::Heap::allocateLarge):
574         * bmalloc/LargeChunk.h:
575         (bmalloc::LargeChunk::get):
576         (bmalloc::LargeChunk::endTag):
577         * bmalloc/Line.h:
578         (bmalloc::Line<Traits>::concurrentRef):
579         (bmalloc::Line<Traits>::deref):
580         * bmalloc/MediumAllocator.h:
581         (bmalloc::MediumAllocator::allocate):
582         * bmalloc/ObjectType.h:
583         (bmalloc::isSmall):
584         * bmalloc/Page.h:
585         (bmalloc::Page<Traits>::ref):
586         (bmalloc::Page<Traits>::deref):
587         * bmalloc/PerThread.h:
588         (bmalloc::PerThread<T>::getSlowCase):
589         * bmalloc/SegregatedFreeList.cpp:
590         (bmalloc::SegregatedFreeList::SegregatedFreeList):
591         (bmalloc::SegregatedFreeList::insert):
592         * bmalloc/SmallAllocator.h:
593         (bmalloc::SmallAllocator::allocate):
594         (bmalloc::SmallAllocator::refill):
595         * bmalloc/Syscall.h:
596         * bmalloc/VMAllocate.h:
597         (bmalloc::vmValidate):
598         (bmalloc::vmAllocate):
599         (bmalloc::vmDeallocatePhysicalPagesSloppy):
600         * bmalloc/Vector.h:
601         (bmalloc::Vector<T>::operator):
602         (bmalloc::Vector<T>::pop):
603         (bmalloc::Vector<T>::shrink):
604         * bmalloc/XLargeChunk.h:
605         (bmalloc::XLargeChunk::range):
606         (bmalloc::XLargeChunk::size):
607
608 2014-04-08  Geoffrey Garen  <ggaren@apple.com>
609
610         Removed an unused file.
611
612         Unreviewed.
613
614         * bmalloc/AsyncTask.cpp: Removed.
615
616 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
617
618         Build bmalloc on Mac
619         https://bugs.webkit.org/show_bug.cgi?id=131333
620
621         Reviewed by Mark Rowe.
622
623         * Makefile: Added. For make clients.
624
625         These files are required for building any project in WebKit. I copied
626         them from WTF:
627         * Configurations: Added.
628         * Configurations/Base.xcconfig: Added.
629         * Configurations/DebugRelease.xcconfig: Added.
630         * Configurations/bmalloc.xcconfig: Added.
631         * Configurations/iOS.xcconfig: Added.
632         * Configurations/mbmalloc.xcconfig: Added.
633
634         * bmalloc.xcodeproj/project.pbxproj: I removed per-project-file stuff
635         from here because everything is in .xcconfig files now.
636
637         I had to fix a bunch of minor warnings, since they're enabled in our
638         .xcconfig files:
639
640         * bmalloc/AsyncTask.h:
641         (bmalloc::Function>::AsyncTask):
642         * bmalloc/BAssert.h:
643         * bmalloc/BoundaryTagInlines.h:
644         (bmalloc::validate):
645         * bmalloc/Heap.cpp:
646         (bmalloc::Heap::Heap):
647         (bmalloc::Heap::allocateLarge):
648         (bmalloc::Heap::deallocateLarge):
649         * bmalloc/Mutex.h:
650         (bmalloc::Mutex::Mutex): Deleted.
651         * bmalloc/VMAllocate.h:
652         (bmalloc::vmValidate):
653         * bmalloc/mbmalloc.cpp:
654
655 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
656
657         bmalloc: Fixed a leak in the per-thread cache
658         https://bugs.webkit.org/show_bug.cgi?id=131330
659
660         Reviewed by Andreas Kling.
661
662         Remember to deallocate our line caches upon thread exit.
663
664         * bmalloc/Deallocator.cpp:
665         (bmalloc::Deallocator::~Deallocator):
666
667 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
668
669         bmalloc: rolled out the tryLock experiment
670         https://bugs.webkit.org/show_bug.cgi?id=131328
671
672         Reviewed by Andreas Kling.
673
674         It wasn't a speedup.
675
676         * bmalloc.xcodeproj/project.pbxproj:
677         * bmalloc/Allocator.cpp:
678         (bmalloc::Allocator::processSmallAllocatorLog):
679         (bmalloc::Allocator::processMediumAllocatorLog):
680         * bmalloc/Deallocator.cpp:
681         (bmalloc::Deallocator::processObjectLog):
682         (bmalloc::Deallocator::deallocateSlowCase):
683         (bmalloc::Deallocator::deallocateSmallLine):
684         (bmalloc::Deallocator::deallocateMediumLine):
685         * bmalloc/Deallocator.h:
686         (bmalloc::Deallocator::deallocateFastCase):
687         * bmalloc/Heap.h:
688         (bmalloc::Heap::deallocateSmallLine):
689         (bmalloc::Heap::deallocateMediumLine):
690         * bmalloc/Line.h:
691         (bmalloc::Line<Traits>::deref):
692         * bmalloc/Page.h:
693         (bmalloc::Page<Traits>::deref):
694
695 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
696
697         bmalloc
698         https://bugs.webkit.org/show_bug.cgi?id=131170
699
700         Reviewed by Andreas Kling.
701
702         Initial commit.
703
704         * bmalloc: Added.
705         * bmalloc.xcodeproj: Added.
706         * bmalloc.xcodeproj/project.pbxproj: Added.
707         * bmalloc/Algorithm.h: Added.
708         (bmalloc::max):
709         (bmalloc::min):
710         (bmalloc::mask):
711         (bmalloc::test):
712         (bmalloc::roundUpToMultipleOf):
713         (bmalloc::roundDownToMultipleOf):
714         (bmalloc::sizeOf):
715         (bmalloc::bitCount):
716         (bmalloc::isPowerOfTwo):
717         * bmalloc/Allocator.cpp: Added.
718         (bmalloc::Allocator::Allocator):
719         (bmalloc::Allocator::~Allocator):
720         (bmalloc::Allocator::log):
721         (bmalloc::Allocator::processSmallAllocatorLog):
722         (bmalloc::Allocator::processMediumAllocatorLog):
723         (bmalloc::Allocator::allocateLarge):
724         (bmalloc::Allocator::allocateXLarge):
725         (bmalloc::Allocator::allocateMedium):
726         (bmalloc::Allocator::allocateSlowCase):
727         * bmalloc/Allocator.h: Added.
728         (bmalloc::Allocator::smallAllocatorFor):
729         (bmalloc::Allocator::allocateFastCase):
730         (bmalloc::Allocator::allocate):
731         * bmalloc/AsyncTask.cpp: Added.
732         (bmalloc::AsyncTask<Function>::runSlowCase):
733         (bmalloc::AsyncTask<Function>::pthreadEntryPoint):
734         (bmalloc::AsyncTask<Function>::entryPoint):
735         * bmalloc/AsyncTask.h: Added.
736         (bmalloc::Function>::AsyncTask):
737         (bmalloc::Function>::join):
738         (bmalloc::Function>::run):
739         (bmalloc::Function>::runSlowCase):
740         (bmalloc::Function>::pthreadEntryPoint):
741         (bmalloc::Function>::entryPoint):
742         * bmalloc/BAssert.h: Added.
743         * bmalloc/BeginTag.h: Added.
744         (bmalloc::BeginTag::isInFreeList):
745         * bmalloc/BoundaryTag.h: Added.
746         (bmalloc::BoundaryTag::isXLarge):
747         (bmalloc::BoundaryTag::setXLarge):
748         (bmalloc::BoundaryTag::isFree):
749         (bmalloc::BoundaryTag::setFree):
750         (bmalloc::BoundaryTag::isEnd):
751         (bmalloc::BoundaryTag::setEnd):
752         (bmalloc::BoundaryTag::hasPhysicalPages):
753         (bmalloc::BoundaryTag::setHasPhysicalPages):
754         (bmalloc::BoundaryTag::isNull):
755         (bmalloc::BoundaryTag::clear):
756         (bmalloc::BoundaryTag::size):
757         (bmalloc::BoundaryTag::setSize):
758         (bmalloc::BoundaryTag::prev):
759         (bmalloc::BoundaryTag::next):
760         * bmalloc/BoundaryTagInlines.h: Added.
761         (bmalloc::validate):
762         (bmalloc::validatePrev):
763         (bmalloc::validateNext):
764         (bmalloc::BoundaryTag::init):
765         (bmalloc::BoundaryTag::mergeLargeLeft):
766         (bmalloc::BoundaryTag::mergeLargeRight):
767         (bmalloc::BoundaryTag::mergeLarge):
768         (bmalloc::BoundaryTag::deallocate):
769         (bmalloc::BoundaryTag::splitLarge):
770         (bmalloc::BoundaryTag::allocate):
771         * bmalloc/Cache.cpp: Added.
772         (bmalloc::Cache::operator new):
773         (bmalloc::Cache::operator delete):
774         (bmalloc::Cache::Cache):
775         (bmalloc::Cache::allocateSlowCase):
776         (bmalloc::Cache::allocateSlowCaseNullCache):
777         (bmalloc::Cache::deallocateSlowCase):
778         (bmalloc::Cache::deallocateSlowCaseNullCache):
779         * bmalloc/Cache.h: Added.
780         (bmalloc::Cache::allocator):
781         (bmalloc::Cache::deallocator):
782         (bmalloc::Cache::allocateFastCase):
783         (bmalloc::Cache::deallocateFastCase):
784         (bmalloc::Cache::allocate):
785         (bmalloc::Cache::deallocate):
786         * bmalloc/Chunk.h: Added.
787         (bmalloc::Chunk::begin):
788         (bmalloc::Chunk::end):
789         (bmalloc::Chunk::lines):
790         (bmalloc::Chunk::pages):
791         * bmalloc/Deallocator.cpp: Added.
792         (bmalloc::Deallocator::Deallocator):
793         (bmalloc::Deallocator::~Deallocator):
794         (bmalloc::Deallocator::deallocateLarge):
795         (bmalloc::Deallocator::deallocateXLarge):
796         (bmalloc::Deallocator::processObjectLog):
797         (bmalloc::Deallocator::deallocateSlowCase):
798         (bmalloc::Deallocator::deallocateSmallLine):
799         (bmalloc::Deallocator::allocateSmallLine):
800         (bmalloc::Deallocator::deallocateMediumLine):
801         (bmalloc::Deallocator::allocateMediumLine):
802         * bmalloc/Deallocator.h: Added.
803         (bmalloc::Deallocator::deallocateFastCase):
804         (bmalloc::Deallocator::deallocate):
805         * bmalloc/EndTag.h: Added.
806         (bmalloc::EndTag::operator=):
807         * bmalloc/FixedVector.h: Added.
808         (bmalloc::FixedVector::begin):
809         (bmalloc::FixedVector::end):
810         (bmalloc::FixedVector::size):
811         (bmalloc::FixedVector::capacity):
812         (bmalloc::FixedVector::clear):
813         (bmalloc::FixedVector::isEmpty):
814         (bmalloc::Capacity>::FixedVector):
815         (bmalloc::Capacity>::operator):
816         (bmalloc::Capacity>::push):
817         (bmalloc::Capacity>::pop):
818         (bmalloc::Capacity>::shrink):
819         * bmalloc/Heap.cpp: Added.
820         (bmalloc::sleep):
821         (bmalloc::Heap::Heap):
822         (bmalloc::Heap::concurrentScavenge):
823         (bmalloc::Heap::scavengeSmallPages):
824         (bmalloc::Heap::scavengeMediumPages):
825         (bmalloc::Heap::scavengeLargeRanges):
826         (bmalloc::Heap::allocateSmallLineSlowCase):
827         (bmalloc::Heap::allocateMediumLineSlowCase):
828         (bmalloc::Heap::allocateXLarge):
829         (bmalloc::Heap::deallocateXLarge):
830         (bmalloc::Heap::allocateLarge):
831         (bmalloc::Heap::deallocateLarge):
832         * bmalloc/Heap.h: Added.
833         (bmalloc::Heap::deallocateSmallLine):
834         (bmalloc::Heap::allocateSmallLine):
835         (bmalloc::Heap::deallocateMediumLine):
836         (bmalloc::Heap::allocateMediumLine):
837         * bmalloc/Inline.h: Added.
838         * bmalloc/LargeChunk.h: Added.
839         (bmalloc::LargeChunk::begin):
840         (bmalloc::LargeChunk::end):
841         (bmalloc::LargeChunk::create):
842         (bmalloc::LargeChunk::get):
843         (bmalloc::LargeChunk::beginTag):
844         (bmalloc::LargeChunk::endTag):
845         * bmalloc/Line.h: Added.
846         (bmalloc::Line<Traits>::begin):
847         (bmalloc::Line<Traits>::end):
848         (bmalloc::Line<Traits>::concurrentRef):
849         (bmalloc::Line<Traits>::deref):
850         * bmalloc/MediumAllocator.h: Added.
851         (bmalloc::MediumAllocator::isNull):
852         (bmalloc::MediumAllocator::MediumAllocator):
853         (bmalloc::MediumAllocator::line):
854         (bmalloc::MediumAllocator::allocate):
855         (bmalloc::MediumAllocator::derefCount):
856         (bmalloc::MediumAllocator::refill):
857         * bmalloc/MediumChunk.h: Added.
858         * bmalloc/MediumLine.h: Added.
859         * bmalloc/MediumPage.h: Added.
860         * bmalloc/MediumTraits.h: Added.
861         * bmalloc/Mutex.cpp: Added.
862         (bmalloc::Mutex::lockSlowCase):
863         * bmalloc/Mutex.h: Added.
864         (bmalloc::Mutex::Mutex):
865         (bmalloc::Mutex::try_lock):
866         (bmalloc::Mutex::lock):
867         (bmalloc::Mutex::unlock):
868         * bmalloc/ObjectType.cpp: Added.
869         (bmalloc::objectType):
870         * bmalloc/ObjectType.h: Added.
871         (bmalloc::isSmallOrMedium):
872         (bmalloc::isSmall):
873         * bmalloc/Page.h: Added.
874         (bmalloc::Page<Traits>::ref):
875         (bmalloc::Page<Traits>::deref):
876         (bmalloc::Page<Traits>::refCount):
877         * bmalloc/PerProcess.h: Added.
878         (bmalloc::PerProcess::mutex):
879         (bmalloc::PerProcess<T>::getFastCase):
880         (bmalloc::PerProcess<T>::get):
881         (bmalloc::PerProcess<T>::getSlowCase):
882         * bmalloc/PerThread.h: Added.
883         (bmalloc::PerThreadStorage<Cache>::get):
884         (bmalloc::PerThreadStorage<Cache>::init):
885         (bmalloc::PerThreadStorage::get):
886         (bmalloc::PerThreadStorage::init):
887         (bmalloc::PerThread<T>::getFastCase):
888         (bmalloc::PerThread<T>::get):
889         (bmalloc::PerThread<T>::destructor):
890         (bmalloc::PerThread<T>::getSlowCase):
891         * bmalloc/Range.h: Added.
892         (bmalloc::Range::Range):
893         (bmalloc::Range::begin):
894         (bmalloc::Range::end):
895         (bmalloc::Range::size):
896         (bmalloc::Range::operator!):
897         (bmalloc::Range::operator<):
898         * bmalloc/SegregatedFreeList.cpp: Added.
899         (bmalloc::SegregatedFreeList::SegregatedFreeList):
900         (bmalloc::SegregatedFreeList::insert):
901         (bmalloc::SegregatedFreeList::takeGreedy):
902         (bmalloc::SegregatedFreeList::take):
903         * bmalloc/SegregatedFreeList.h: Added.
904         * bmalloc/Sizes.h: Added.
905         * bmalloc/SmallAllocator.h: Added.
906         (bmalloc::SmallAllocator::isNull):
907         (bmalloc::SmallAllocator::canAllocate):
908         (bmalloc::SmallAllocator::SmallAllocator):
909         (bmalloc::SmallAllocator::line):
910         (bmalloc::SmallAllocator::allocate):
911         (bmalloc::SmallAllocator::objectCount):
912         (bmalloc::SmallAllocator::derefCount):
913         (bmalloc::SmallAllocator::refill):
914         * bmalloc/SmallChunk.h: Added.
915         * bmalloc/SmallLine.h: Added.
916         * bmalloc/SmallPage.h: Added.
917         * bmalloc/SmallTraits.h: Added.
918         * bmalloc/Syscall.h: Added.
919         * bmalloc/VMAllocate.h: Added.
920         (bmalloc::vmSize):
921         (bmalloc::vmValidate):
922         (bmalloc::vmAllocate):
923         (bmalloc::vmDeallocate):
924         (bmalloc::vmDeallocatePhysicalPages):
925         (bmalloc::vmAllocatePhysicalPages):
926         (bmalloc::vmDeallocatePhysicalPagesSloppy):
927         (bmalloc::vmAllocatePhysicalPagesSloppy):
928         * bmalloc/VMHeap.cpp: Added.
929         (bmalloc::VMHeap::VMHeap):
930         (bmalloc::VMHeap::allocateSmallChunk):
931         (bmalloc::VMHeap::allocateMediumChunk):
932         (bmalloc::VMHeap::allocateLargeChunk):
933         * bmalloc/VMHeap.h: Added.
934         (bmalloc::VMHeap::allocateSmallPage):
935         (bmalloc::VMHeap::allocateMediumPage):
936         (bmalloc::VMHeap::allocateLargeRange):
937         (bmalloc::VMHeap::deallocateSmallPage):
938         (bmalloc::VMHeap::deallocateMediumPage):
939         (bmalloc::VMHeap::deallocateLargeRange):
940         * bmalloc/Vector.h: Added.
941         (bmalloc::Vector::begin):
942         (bmalloc::Vector::end):
943         (bmalloc::Vector::size):
944         (bmalloc::Vector::capacity):
945         (bmalloc::Vector::last):
946         (bmalloc::Vector::pop):
947         (bmalloc::Vector<T>::Vector):
948         (bmalloc::Vector<T>::~Vector):
949         (bmalloc::Vector<T>::operator):
950         (bmalloc::Vector<T>::push):
951         (bmalloc::Vector<T>::pop):
952         (bmalloc::Vector<T>::shrink):
953         (bmalloc::Vector<T>::reallocateBuffer):
954         (bmalloc::Vector<T>::shrinkCapacity):
955         (bmalloc::Vector<T>::growCapacity):
956         * bmalloc/XLargeChunk.h: Added.
957         (bmalloc::XLargeChunk::get):
958         (bmalloc::XLargeChunk::begin):
959         (bmalloc::XLargeChunk::XLargeChunk):
960         (bmalloc::XLargeChunk::create):
961         (bmalloc::XLargeChunk::destroy):
962         (bmalloc::XLargeChunk::range):
963         (bmalloc::XLargeChunk::size):
964         * bmalloc/bmalloc.h: Added.
965         (bmalloc::api::malloc):
966         (bmalloc::api::free):
967         (bmalloc::api::realloc):
968         * bmalloc/mbmalloc.cpp: Added.
969