heroku / heroku/barnes

Support loading on Windows, use CLOCK_REALTIME or CLOCK_MONOTONIC

Open
#40 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
85
Forks
0
Avg merge
2d 18h
Merged PRs (30d)
1

Description

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`](https://github.com/heroku/barnes/blob/b690e31abfb745cb533922fa77674309c00a2f7f/lib/barnes/instruments/stopwatch.rb#L77). 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](https://github.com/ruby/ruby/blob/6d93644ba1c1eb662f9186019b69da44b71be32e/win32/win32.c#L4701) `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'

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/barnes/instruments/stopwatch.rb at line 77 and follow the cpu, current, and start! paths shown in the stack trace. Reproduce Barnes startup on Windows and verify that it no longer raises Errno::EINVAL when loading, while preserving the reported runtime metrics.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
observability-sre
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.