Descriptionruntime: implement transfer cache
Currently we do the following dance after sweeping a span:
1. lock mcentral
2. remove the span from a list
3. unlock mcentral
4. unmark span
5. lock mheap
6. insert the span into heap
7. unlock mheap
8. lock mcentral
9. observe empty list
10. unlock mcentral
11. lock mheap
12. grab the span
13. unlock mheap
14. mark span
15. lock mcentral
16. insert the span into empty list
17. unlock mcentral
This change short-circuits this sequence to nothing,
that is, we just cache and use the span after sweeping.
This gives us functionality similar (even better) to tcmalloc's transfer cache.
benchmark old ns/op new ns/op delta
BenchmarkMalloc8 22.2 19.5 -12.16%
BenchmarkMalloc16 31.0 26.6 -14.19%
Patch Set 1 #Patch Set 2 : diff -r 3b3e7fe70577b153f3c67532bbdc92f7312d7126 https://dvyukov%40google.com@code.google.com/p/go/ #Patch Set 3 : diff -r 3b3e7fe70577b153f3c67532bbdc92f7312d7126 https://dvyukov%40google.com@code.google.com/p/go/ #Patch Set 4 : diff -r 3b3e7fe70577b153f3c67532bbdc92f7312d7126 https://dvyukov%40google.com@code.google.com/p/go/ #Patch Set 5 : diff -r 3b3e7fe70577b153f3c67532bbdc92f7312d7126 https://dvyukov%40google.com@code.google.com/p/go/ #
Total comments: 4
Patch Set 6 : diff -r 7718fcdf33800c8fa0b640047d847178287d548e https://dvyukov%40google.com@code.google.com/p/go/ #
MessagesTotal messages: 6
|