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