globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

Separate read/write network timeouts #161

Closed domodwyer closed 6 years ago

domodwyer commented 6 years ago

Fixes #160.

Defines two new DialInfo fields: ReadTimeout, and WriteTimeout, defaulting to DialInfo.Timeout for backwards compatibility.

Removes passing multiple copies of the timeout value throughout the codebase, instead keeping a reference to a copy of the DialInfo which should make future refactoring easier (all the information is available everywhere, rather than ad-hock passing in function arguments).

As a nice bonus, because the same DialInfo instance is referenced by all sockets rather than each socket referencing its own copy of the timeout value in the hot path, the increased cache locality has reduced operation latency by ~15% resulting in ~1700/s increase in read throughput.


throughput-overview

efe0945164a7e582241f37ae8983c075f8f2e870-timeout-insert-latency.txt efe0945164a7e582241f37ae8983c075f8f2e870-timeout-insert-throughput.txt efe0945164a7e582241f37ae8983c075f8f2e870-timeout-select-zipfian-latency.txt efe0945164a7e582241f37ae8983c075f8f2e870-timeout-select-zipfian-throughput.txt efe0945164a7e582241f37ae8983c075f8f2e870-timeout-update-zipfian-latency.txt efe0945164a7e582241f37ae8983c075f8f2e870-timeout-update-zipfian-throughput.txt