Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
database/sql: Lock contention in func (rs *Rows) Scan #7086
While doing profiling of one tool I found what function Rows.Scan() is suffering from lock contention. The reason is what function convertAssign() use fmt.Sprintf() to convert rows data to desired type. So if you read a lot of data from database and use num processors > 1 you can get result like in attached before.svg. I see there 2 problems: 1. Lock contention in function fmt.newPrinter()/free() 2. A lot of time spend inside fmt.doPrintf() This issue is not about fmt package itself, my proposal is to use functions from strconv package instead of calling fmt.Sprintf("%v", src). As you can see on the second profiling, after replacing fmt.Sprintf() to strconv.FormatBool/FormatFloat/FormatInt performance of Scanf increased about 2 times. I can submit my patch for this improvement if you would like to accept this issue. Environment: OS: RHEL 6.5 Go version: 1.2 and development 24 CPU's