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

Support loading on Windows, use CLOCK_REALTIME or CLOCK_MONOTONIC #40

Open
ariccio opened this issue Sep 24, 2022 · 0 comments
Open

Support loading on Windows, use CLOCK_REALTIME or CLOCK_MONOTONIC #40

ariccio opened this issue Sep 24, 2022 · 0 comments

Comments

@ariccio
Copy link

ariccio commented Sep 24, 2022

Strangely, for the first time ever tonight, Rails failed to start on my windows dev machine because Barnes tries to use Process.clock_gettime with Process::CLOCK_PROCESS_CPUTIME_ID. Again, I have no clue why this is an issue all of a sudden. I haven't changed anything reasonably related since last successful start. Either way, Ruby on Windows only currently supports CLOCK_REALTIME and CLOCK_MONOTONIC.

It's easy for me to workaround, since I don't actually need barnes in development or test, so I just add it to the :production group in my gemfile. Perhaps someone should update the docs to say it should be added in production? Or otherwise nop out the code.

The stacktrace is:

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:77:in `clock_gettime': Invalid argument - clock_gettime (Errno::EINVAL)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:77:in `cpu'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:64:in `current'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:33:in `start!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/panel.rb:38:in `block in start!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/panel.rb:37:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/panel.rb:37:in `start!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/periodic.rb:43:in `block (2 levels) in initialize'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/periodic.rb:42:in `each'

ariccio added a commit to ariccio/COVID-CO2-tracker that referenced this issue Sep 24, 2022
All of a sudden, barnes was crashing in dev [on `clock_gettime`](https://github.com/heroku/barnes/blob/b690e31abfb745cb533922fa77674309c00a2f7f/lib/barnes/instruments/stopwatch.rb#L77), since windows does not support `CLOCK_PROCESS_CPUTIME_ID`. Workaround just by disabling in dev and test.

See: heroku/barnes#40
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

1 participant