FAQ
today, when a learn the code of sync/mutex.go, i find a prev version of
mutex.go , it's very simple and sometime fast than the current version code.

this is the diff of the two version:
https://code.google.com/p/go/source/diff?path=/src/pkg/sync/mutex.go&format=side&r=e540ff37120defc1f79081bb4f5f603915f568bd&old_path=/src/pkg/sync/mutex.go&old=5ddd27ff66f622deebb0925ea07238abac8af0a4


this is my benchmark result:

prev version :

BenchmarkMutexUncontended 100000000 19.0 ns/op
BenchmarkMutex 100000000 19.2 ns/op
BenchmarkMutexSlack 100000000 29.7 ns/op
BenchmarkMutexWork 10000000 228 ns/op
BenchmarkMutexWorkSlack 10000000 228 ns/op


current version:

BenchmarkMutexUncontended 100000000 22.1 ns/op
BenchmarkMutex 100000000 22.6 ns/op
BenchmarkMutexSlack 100000000 22.6 ns/op
BenchmarkMutexWork 10000000 230 ns/op
BenchmarkMutexWorkSlack 10000000 230 ns/op

go version go1.1.1 windows/amd64

why we must use a more long and complex code ?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Jun 24, 2013 at 11:49 am
    You should read the description that accompanied that change. It explains tge rational for te change.

    https://code.google.com/p/go/source/detail?r=e540ff37120defc1f79081bb4f5f603915f568bd


    On 24/06/2013, at 21:44, golangwzw wrote:

    today, when a learn the code of sync/mutex.go, i find a prev version of mutex.go , it's very simple and sometime fast than the current version code.

    this is the diff of the two version:
    https://code.google.com/p/go/source/diff?path=/src/pkg/sync/mutex.go&format=side&r=e540ff37120defc1f79081bb4f5f603915f568bd&old_path=/src/pkg/sync/mutex.go&old=5ddd27ff66f622deebb0925ea07238abac8af0a4


    this is my benchmark result:

    prev version :

    BenchmarkMutexUncontended 100000000 19.0 ns/op
    BenchmarkMutex 100000000 19.2 ns/op
    BenchmarkMutexSlack 100000000 29.7 ns/op
    BenchmarkMutexWork 10000000 228 ns/op
    BenchmarkMutexWorkSlack 10000000 228 ns/op


    current version:

    BenchmarkMutexUncontended 100000000 22.1 ns/op
    BenchmarkMutex 100000000 22.6 ns/op
    BenchmarkMutexSlack 100000000 22.6 ns/op
    BenchmarkMutexWork 10000000 230 ns/op
    BenchmarkMutexWorkSlack 10000000 230 ns/op

    go version go1.1.1 windows/amd64

    why we must use a more long and complex code ?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Golangwzw at Jun 24, 2013 at 12:18 pm
    thank you very much. i benchmark in multi-thread, this is the new result:

    benchmark old ns/op new ns/op delta

    BenchmarkMutexUncontended-4 5.3 7.5
      41.51%
    BenchmarkMutex-4 93.5 125 33.68%
    BenchmarkMutexSlack-4 139 137 -1.43%
    BenchmarkMutexWork-4 116 81.9 -29.40%
    BenchmarkMutexWorkSlack-4 140 102 -27.14%


    not very the same to
    https://code.google.com/p/go/source/detail?spec=svne540ff37120defc1f79081bb4f5f603915f568bd&r=e540ff37120defc1f79081bb4f5f603915f568bd
    but i think the new version is better.
    On Monday, June 24, 2013 7:49:37 PM UTC+8, Dave Cheney wrote:

    You should read the description that accompanied that change. It explains
    tge rational for te change.


    https://code.google.com/p/go/source/detail?r=e540ff37120defc1f79081bb4f5f603915f568bd



    On 24/06/2013, at 21:44, golangwzw <vip...@vip.qq.com <javascript:>>
    wrote:

    today, when a learn the code of sync/mutex.go, i find a prev version of
    mutex.go , it's very simple and sometime fast than the current version code.

    this is the diff of the two version:

    https://code.google.com/p/go/source/diff?path=/src/pkg/sync/mutex.go&format=side&r=e540ff37120defc1f79081bb4f5f603915f568bd&old_path=/src/pkg/sync/mutex.go&old=5ddd27ff66f622deebb0925ea07238abac8af0a4


    this is my benchmark result:

    prev version :

    BenchmarkMutexUncontended 100000000 19.0 ns/op
    BenchmarkMutex 100000000 19.2 ns/op
    BenchmarkMutexSlack 100000000 29.7 ns/op
    BenchmarkMutexWork 10000000 228 ns/op
    BenchmarkMutexWorkSlack 10000000 228 ns/op


    current version:

    BenchmarkMutexUncontended 100000000 22.1 ns/op
    BenchmarkMutex 100000000 22.6 ns/op
    BenchmarkMutexSlack 100000000 22.6 ns/op
    BenchmarkMutexWork 10000000 230 ns/op
    BenchmarkMutexWorkSlack 10000000 230 ns/op

    go version go1.1.1 windows/amd64

    why we must use a more long and complex code ?

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Jun 24, 2013 at 12:21 pm
    Your numbers are jumping around a lot. Have you properly isolated your machine, disabled power saving, etc?


    On 24/06/2013, at 22:18, golangwzw wrote:


    thank you very much. i benchmark in multi-thread, this is the new result:
    benchmark old ns/op new ns/op delta
    BenchmarkMutexUncontended-4 5.3 7.5 41.51%
    BenchmarkMutex-4 93.5 125 33.68%
    BenchmarkMutexSlack-4 139 137 -1.43%
    BenchmarkMutexWork-4 116 81.9 -29.40%
    BenchmarkMutexWorkSlack-4 140 102 -27.14%


    not very the same to https://code.google.com/p/go/source/detail?spec=svne540ff37120defc1f79081bb4f5f603915f568bd&r=e540ff37120defc1f79081bb4f5f603915f568bd
    but i think the new version is better.
    On Monday, June 24, 2013 7:49:37 PM UTC+8, Dave Cheney wrote:

    You should read the description that accompanied that change. It explains tge rational for te change.

    https://code.google.com/p/go/source/detail?r=e540ff37120defc1f79081bb4f5f603915f568bd


    On 24/06/2013, at 21:44, golangwzw wrote:

    today, when a learn the code of sync/mutex.go, i find a prev version of mutex.go , it's very simple and sometime fast than the current version code.

    this is the diff of the two version:
    https://code.google.com/p/go/source/diff?path=/src/pkg/sync/mutex.go&format=side&r=e540ff37120defc1f79081bb4f5f603915f568bd&old_path=/src/pkg/sync/mutex.go&old=5ddd27ff66f622deebb0925ea07238abac8af0a4


    this is my benchmark result:

    prev version :

    BenchmarkMutexUncontended 100000000 19.0 ns/op
    BenchmarkMutex 100000000 19.2 ns/op
    BenchmarkMutexSlack 100000000 29.7 ns/op
    BenchmarkMutexWork 10000000 228 ns/op
    BenchmarkMutexWorkSlack 10000000 228 ns/op


    current version:

    BenchmarkMutexUncontended 100000000 22.1 ns/op
    BenchmarkMutex 100000000 22.6 ns/op
    BenchmarkMutexSlack 100000000 22.6 ns/op
    BenchmarkMutexWork 10000000 230 ns/op
    BenchmarkMutexWorkSlack 10000000 230 ns/op

    go version go1.1.1 windows/amd64

    why we must use a more long and complex code ?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Golangwzw at Jun 24, 2013 at 12:34 pm
    i disable the the power saving, this is the new result.

        benchmarkold ns/opnew ns/op delt BenchmarkMutexUncontended-44.965.77
    16.33% BenchmarkMutex-491.812232.90% BenchmarkMutexSlack-4139137-1.44%
    BenchmarkMutexWork-411582.9-27.91% BenchmarkMutexWorkSlack-4144102-29.17%
    the first BenchmarkMutexUncontended-4 change a lot.
    On Monday, June 24, 2013 8:21:27 PM UTC+8, Dave Cheney wrote:

    Your numbers are jumping around a lot. Have you properly isolated your
    machine, disabled power saving, etc?



    On 24/06/2013, at 22:18, golangwzw <vip...@vip.qq.com <javascript:>>
    wrote:


    thank you very much. i benchmark in multi-thread, this is the new result:

    benchmark old ns/op new ns/op delta

    BenchmarkMutexUncontended-4 5.3 7.5
    41.51%
    BenchmarkMutex-4 93.5 125 33.68%
    BenchmarkMutexSlack-4 139 137 -1.43%
    BenchmarkMutexWork-4 116 81.9 -29.40%
    BenchmarkMutexWorkSlack-4 140 102 -27.14%


    not very the same to
    https://code.google.com/p/go/source/detail?spec=svne540ff37120defc1f79081bb4f5f603915f568bd&r=e540ff37120defc1f79081bb4f5f603915f568bd
    but i think the new version is better.
    On Monday, June 24, 2013 7:49:37 PM UTC+8, Dave Cheney wrote:

    You should read the description that accompanied that change. It explains
    tge rational for te change.


    https://code.google.com/p/go/source/detail?r=e540ff37120defc1f79081bb4f5f603915f568bd



    On 24/06/2013, at 21:44, golangwzw wrote:

    today, when a learn the code of sync/mutex.go, i find a prev version of
    mutex.go , it's very simple and sometime fast than the current version code.

    this is the diff of the two version:

    https://code.google.com/p/go/source/diff?path=/src/pkg/sync/mutex.go&format=side&r=e540ff37120defc1f79081bb4f5f603915f568bd&old_path=/src/pkg/sync/mutex.go&old=5ddd27ff66f622deebb0925ea07238abac8af0a4


    this is my benchmark result:

    prev version :

    BenchmarkMutexUncontended 100000000 19.0 ns/op
    BenchmarkMutex 100000000 19.2 ns/op
    BenchmarkMutexSlack 100000000 29.7 ns/op
    BenchmarkMutexWork 10000000 228 ns/op
    BenchmarkMutexWorkSlack 10000000 228 ns/op


    current version:

    BenchmarkMutexUncontended 100000000 22.1 ns/op
    BenchmarkMutex 100000000 22.6 ns/op
    BenchmarkMutexSlack 100000000 22.6 ns/op
    BenchmarkMutexWork 10000000 230 ns/op
    BenchmarkMutexWorkSlack 10000000 230 ns/op

    go version go1.1.1 windows/amd64

    why we must use a more long and complex code ?

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.



    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dmitry Vyukov at Jun 24, 2013 at 12:59 pm

    On Mon, Jun 24, 2013 at 3:44 PM, golangwzw wrote:
    today, when a learn the code of sync/mutex.go, i find a prev version of
    mutex.go , it's very simple and sometime fast than the current version code.

    The old code is good only for synthetic benchmarks.

    this is the diff of the two version:
    https://code.google.com/p/go/source/diff?path=/src/pkg/sync/mutex.go&format=side&r=e540ff37120defc1f79081bb4f5f603915f568bd&old_path=/src/pkg/sync/mutex.go&old=5ddd27ff66f622deebb0925ea07238abac8af0a4


    this is my benchmark result:

    prev version :

    BenchmarkMutexUncontended 100000000 19.0 ns/op
    BenchmarkMutex 100000000 19.2 ns/op
    BenchmarkMutexSlack 100000000 29.7 ns/op
    BenchmarkMutexWork 10000000 228 ns/op
    BenchmarkMutexWorkSlack 10000000 228 ns/op


    current version:

    BenchmarkMutexUncontended 100000000 22.1 ns/op
    BenchmarkMutex 100000000 22.6 ns/op
    BenchmarkMutexSlack 100000000 22.6 ns/op
    BenchmarkMutexWork 10000000 230 ns/op
    BenchmarkMutexWorkSlack 10000000 230 ns/op

    go version go1.1.1 windows/amd64

    why we must use a more long and complex code ?
    because it's better for real programs

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 24, '13 at 11:44a
activeJun 24, '13 at 12:59p
posts6
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase