Skip to content

runtime: reduce scheduling contention for large $GOMAXPROCS #2933

@gopherbot

Description

@gopherbot

by apachephp:

I run  benchmark against MySQL, there are multiple threads (goroutine)
connecting to MySQL and running short queries.

In this scenario go application uses most CPU resources,
and from profiling it seems that is related to Mutex usage in Net Read

Profiling:
(pprof) top20 -cum
Total: 528260 samples
       0   0.0%   0.0%   412464  78.1% runtime.initdone
      22   0.0%   0.0%   401608  76.0% main.sleepy
      22   0.0%   0.0%   400454  75.8% main.runQuery
     587   0.1%   0.1%   393491  74.5% github%2ecom/Philio/GoMySQL..getResult
    1155   0.2%   0.3%   370480  70.1% github%2ecom/Philio/GoMySQL..readPacket
      26   0.0%   0.3%   356381  67.5% github%2ecom/Philio/GoMySQL..StoreResult
     136   0.0%   0.4%   356135  67.4% github%2ecom/Philio/GoMySQL..getAllRows
     138   0.0%   0.4%   356026  67.4% github%2ecom/Philio/GoMySQL..getRow
     371   0.1%   0.5%   329772  62.4% io.ReadFull
     801   0.2%   0.6%   329470  62.4% io.ReadAtLeast
    1627   0.3%   0.9%   328820  62.2% net..Read
  317879  60.2%  61.1%   317879  60.2% runtime.futex
   23042   4.4%  65.5%   297638  56.3% syscall.Syscall
     524   0.1%  65.6%   293808  55.6% syscall.Read
   15311   2.9%  68.5%   243751  46.1% runtime.entersyscall
     973   0.2%  68.6%   236760  44.8% github%2ecom/Philio/GoMySQL..readNumber
      88   0.0%  68.7%   182475  34.5% futexwakeup
     316   0.1%  68.7%   179999  34.1% schedunlock
     166   0.0%  68.8%   162654  30.8% runtime.unlock
     168   0.0%  68.8%   162546  30.8% futexunlock

Is there way to use mutex for shorter period of time in such scenario ?
With such problem I can't use go application for benchmarking, as it consumes for CPU
than MySQL

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions