Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issues: runtime.mallocgc is eating CPU #506

Open
jvegaseg opened this issue Jul 11, 2020 · 2 comments
Open

Performance issues: runtime.mallocgc is eating CPU #506

jvegaseg opened this issue Jul 11, 2020 · 2 comments
Assignees

Comments

@jvegaseg
Copy link

jvegaseg commented Jul 11, 2020

We have developed a proxy and it is running well but it consumes a lot of CPU.
We use sync.Pool in order to preallocate what we need, but at then end, we call to the funcion BuildSimpleTextResultset which is who eats the CPU (I suppose because it is using a lot of slice appends).

Using perf tool, it reports that runtime.mallocgc is eating mayor part of the CPU.

Is there any way to get better performance? Have you plan to use sync.Pool or another way of preallocated memory?

Regards,

@jvegaseg
Copy link
Author

28.43% allocations cames from PutLengthEncodedString

Showing nodes accounting for 1153931878, 88.55% of 1303169998 total
Dropped 163 nodes (cum <= 6515849)
Showing top 10 nodes out of 51
      flat  flat%   sum%        cum   cum%
 369422822 28.35% 28.35%  370504182 28.43%  github.com/siddontang/go-mysql/mysql.PutLengthEncodedString
 243506439 18.69% 47.03%  331471742 25.44%  database/sql.convertAssignRows
 241409223 18.52% 65.56%  241409223 18.52%  github.com/go-sql-driver/mysql.(*textRows).readRow
 109795022  8.43% 73.98%  348460452 26.74%  github.com/siddontang/go-mysql/mysql.BuildSimpleTextResultset
  87965303  6.75% 80.73%   87965303  6.75%  database/sql.cloneBytes (inline)
  40888957  3.14% 83.87%   40888957  3.14%  main.MemoryPoolGetRowValue
  21476391  1.65% 85.52%  153315143 11.76%  github.com/siddontang/go-mysql/mysql.(*Field).Dump
  16056865  1.23% 86.75%   16056865  1.23%  main.(*ProxyStats).Finish
  13776820  1.06% 87.81%   13776820  1.06%  github.com/go-sql-driver/mysql.(*mysqlConn).readColumns
   9634036  0.74% 88.55%   16941591  1.30%  main.(*ProxyHandler).executeOneCommand

@atercattus
Copy link
Member

Hello.
This is in the plans for the near future.
First step was #466 but there is still a lot of work to be done.

@atercattus atercattus self-assigned this Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants