Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(134)

Issue 119550043: code review 119550043: runtime: implement transfer cache (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by dvyukov
Modified:
10 years, 8 months ago
Reviewers:
khr
CC:
golang-codereviews, khr, rlh, rsc
Visibility:
Public.

Description

runtime: 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/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -45 lines) Patch
M src/pkg/runtime/malloc.h View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/pkg/runtime/mcentral.c View 1 2 3 4 5 8 chunks +48 lines, -38 lines 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 3 4 5 5 chunks +8 lines, -4 lines 0 comments Download
M src/pkg/runtime/mheap.c View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 6
dvyukov
Hello golang-codereviews@googlegroups.com (cc: khr@golang.org, rlh@golang.org, rsc@golang.org), I'd like you to review this change to https://dvyukov%40google.com@code.google.com/p/go/
10 years, 9 months ago (2014-08-07 17:36:05 UTC) #1
dvyukov
ping
10 years, 9 months ago (2014-08-12 20:35:17 UTC) #2
khr
On 2014/08/12 20:35:17, dvyukov wrote: > ping LGTM.
10 years, 8 months ago (2014-08-17 23:27:32 UTC) #3
khr
https://codereview.appspot.com/119550043/diff/80001/src/pkg/runtime/mcentral.c File src/pkg/runtime/mcentral.c (right): https://codereview.appspot.com/119550043/diff/80001/src/pkg/runtime/mcentral.c#newcode70 src/pkg/runtime/mcentral.c:70: // the span could be moved to nonempty or ...
10 years, 8 months ago (2014-08-17 23:27:43 UTC) #4
dvyukov
https://codereview.appspot.com/119550043/diff/80001/src/pkg/runtime/mcentral.c File src/pkg/runtime/mcentral.c (right): https://codereview.appspot.com/119550043/diff/80001/src/pkg/runtime/mcentral.c#newcode70 src/pkg/runtime/mcentral.c:70: // the span could be moved to nonempty or ...
10 years, 8 months ago (2014-08-18 12:52:17 UTC) #5
dvyukov
10 years, 8 months ago (2014-08-18 12:52:36 UTC) #6
*** Submitted as https://code.google.com/p/go/source/detail?r=b86ee06ef235 ***

runtime: 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%

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rlh, rsc
https://codereview.appspot.com/119550043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b