jhawthorn / vernier

📏 next generation CRuby profiler
https://vernier.prof/
MIT License
837 stars 20 forks source link

`Encoding::UndefinedConversionError` when writing to gz #70

Closed technicalpickles closed 6 months ago

technicalpickles commented 6 months ago

When profiling our app's boot-time, I typically use rails runner true as a gauge. I'm trying to run that with vernier run, but seeing errors:

$ DISABLE_SPRING=1 bundle exec vernier run -- bin/rails runner true
starting profiler with interval 500
/Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/vernier-1.0.0/lib/vernier/result.rb:46:in `write': "\x8B" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
    from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/vernier-1.0.0/lib/vernier/result.rb:46:in `write'
    from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/vernier-1.0.0/lib/vernier/autorun.rb:34:in `stop'
    from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/vernier-1.0.0/lib/vernier/autorun.rb:45:in `at_exit'
    from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/vernier-1.0.0/lib/vernier/autorun.rb:66:in `block in <top (required)>'

I also tried DISABLE_SPRING=1 bundle exec vernier run -- bundle exec rails runner true to bundle exec it, with the same error

Details

technicalpickles commented 6 months ago

Looks like the default is to write to a GZIP, ie https://github.com/jhawthorn/vernier/blob/f8976625d7b5cfeeddb8471750f1ca93cf10d5aa/lib/vernier/autorun.rb#L32-L33

I found that you can set options via environment variables https://github.com/jhawthorn/vernier/blob/f8976625d7b5cfeeddb8471750f1ca93cf10d5aa/lib/vernier/autorun.rb#L12-L16

I was able to get it working by setting VERNIER_OUTPUT, ie VERNIER_OUTPUT=tmp/vernier.json.gz DISABLE_SPRING=1 bundle exec vernier run -- bundle exec rails runner true