Code Monkey home page Code Monkey logo

trf's Introduction

trf

windows timer resolution fix for go

this issue was once fixed by https://go-review.googlesource.com/#/c/17164/ in go 1.6 , but go 1.7 revert the above changes by some reasons , so you may want to import this package again in go 1.7.

https://tip.golang.org/doc/go1.7

"On Windows, Go programs in Go 1.5 and earlier forced the global Windows timer resolution to 1ms at startup by calling timeBeginPeriod(1). Changing the global timer resolution caused problems on some systems, and testing suggested that the call was not needed for good scheduler performance, so Go 1.6 removed the call. Go 1.7 brings the call back: under some workloads the call is still needed for good scheduler performance."

in windows, go runtime calls timeBeginPeriod when initialization, and set the system timer resolution to 1ms.

actually, all .exe files build by go, will hold a 1ms system timer resolution until quit.

such behavior, which chrome used to have, is proved to be not battery friendly.

i have reported a issue here.

before this behavior is changed in future, you can simply import this package in your project to solve it.

import _ "github.com/defia/trf"

that's all. the package calls timeEndPeriod on start, so the system timer resolution change made by runtime will be discarded.

it may have impact on performance, but if your client stays background for a long time, such as cow , shadowsocks-go , gocode on your windows laptop, i don't see any slow down but the battery life will be definitely better.

trf's People

Contributors

defia avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.