Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ just test
The test suite executes a number of sample programs in `test/programs` under
the two separate recorders/tracers:

* One based on a Ruby native extension in `gems/native-tracer`
* Another based on pure Ruby code in `gems/pure-ruby-tracer`
* One based on a Ruby native extension in `gems/codetracer-ruby-recorder`
* Another based on pure Ruby code in `gems/codetracer-pure-ruby-recorder`

Their outputs are compared structurally to known good outputs stored
in `test/fixtures`.

When `just test` fails, I suggest running the two tracers directly and
analyzing where their outputs differs.

Please note that only the pure-ruby-tracer formats the output json for
Please note that only the codetracer-pure-ruby-recorder formats the output json for
human readability. Thus, you must use `jq -S` when comparing the outputs.

To run the benchmark, execute:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

source "https://rubygems.org"

gem "codetracer-ruby-recorder", path: "gems/native-tracer"
gem "codetracer_pure_ruby_recorder", path: "gems/pure-ruby-tracer"
gem "codetracer-ruby-recorder", path: "gems/codetracer-ruby-recorder"
gem "codetracer-pure-ruby-recorder", path: "gems/codetracer-pure-ruby-recorder"
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ bench pattern="*" write_report="console":
ruby test/benchmarks/run_benchmarks.rb '{{pattern}}' --write-report={{write_report}}

build-extension:
cargo build --release --manifest-path gems/native-tracer/ext/native_tracer/Cargo.toml
cargo build --release --manifest-path gems/codetracer-ruby-recorder/ext/native_tracer/Cargo.toml
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ just build-extension

This compiles the extension in release mode using Cargo. The resulting
shared library is placed under
`ext/native_tracer/target/release/` and is loaded by `gems/native-tracer/lib/native_trace.rb`.
`ext/native_tracer/target/release/` and is loaded by `gems/codetracer-ruby-recorder/lib/native_trace.rb`.

## Running tests

Expand Down Expand Up @@ -59,7 +59,7 @@ Two Ruby gems are published from this repository:
* **codetracer-ruby-recorder** – the tracer with the compiled native
extension. Prebuilt gems are produced per target platform using
[`rb_sys`](https://github.com/oxidize-rb/rb-sys).
* **codetracer_pure_ruby_recorder** – a pure Ruby fallback without the
* **codetracer-pure-ruby-recorder** – a pure Ruby fallback without the
native extension.

A helper script is available to build and push all gems in one go:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The command downloads a prebuilt native extension when available and falls back
to building it from source. If this fails, install the pure Ruby version:

```bash
gem install codetracer_pure_ruby_recorder
gem install codetracer-pure-ruby-recorder
```

After installing, load the tracer:
Expand All @@ -36,7 +36,7 @@ recorder.flush_trace(Dir.pwd)
you can currently use it directly with

```bash
ruby gems/pure-ruby-tracer/lib/trace.rb [--out-dir DIR] <path to ruby file>
ruby gems/codetracer-pure-ruby-recorder/lib/trace.rb [--out-dir DIR] <path to ruby file>
# produces several trace json files in DIR,
# or in `$CODETRACER_RUBY_RECORDER_OUT_DIR` if DIR is not provided.
# Defaults to the current directory.
Expand All @@ -47,7 +47,7 @@ You can also invoke a lightweight CLI that loads the native tracer extension
directly:

```bash
ruby gems/native-tracer/lib/native_trace.rb [--out-dir DIR] <path to ruby file>
ruby gems/codetracer-ruby-recorder/lib/native_trace.rb [--out-dir DIR] <path to ruby file>
# Uses DIR or `$CODETRACER_RUBY_RECORDER_OUT_DIR` to choose where traces are saved.
```

Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rb_sys/extensiontask'

RbSys::ExtensionTask.new('codetracer_ruby_recorder') do |ext|
ext.ext_dir = 'gems/native-tracer/ext/native_tracer'
ext.lib_dir = 'gems/native-tracer/lib'
ext.gem_spec = Gem::Specification.load('gems/native-tracer/codetracer-ruby-recorder.gemspec')
ext.ext_dir = 'gems/codetracer-ruby-recorder/ext/native_tracer'
ext.lib_dir = 'gems/codetracer-ruby-recorder/lib'
ext.gem_spec = Gem::Specification.load('gems/codetracer-ruby-recorder/codetracer-ruby-recorder.gemspec')
end
2 changes: 1 addition & 1 deletion examples/selective_tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Load the native extension only if RubyRecorder is not already available
# (e.g., when running directly without the codetracer wrapper)
unless defined?(RubyRecorder)
ext_base = File.expand_path('../gems/native-tracer/ext/native_tracer/target/release/libcodetracer_ruby_recorder', __dir__)
ext_base = File.expand_path('../gems/codetracer-ruby-recorder/ext/native_tracer/target/release/libcodetracer_ruby_recorder', __dir__)
require ext_base
end

Expand Down
2 changes: 1 addition & 1 deletion examples/selective_tracing_pure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Load the pure Ruby tracer library if RubyRecorder is not already defined
unless defined?(RubyRecorder)
lib_base = File.expand_path('../gems/pure-ruby-tracer/lib/codetracer_pure_ruby_recorder', __dir__)
lib_base = File.expand_path('../gems/codetracer-pure-ruby-recorder/lib/codetracer_pure_ruby_recorder', __dir__)
require lib_base
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Gem::Specification.new do |spec|
spec.name = 'codetracer_pure_ruby_recorder'
spec.version = '0.1.0'
spec.name = 'codetracer-pure-ruby-recorder'
version_file = File.expand_path('../../version.txt', __dir__)
spec.version = File.read(version_file).strip
spec.authors = ['Metacraft Labs']
spec.email = ['[email protected]']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Gem::Specification.new do |spec|
spec.name = 'codetracer-ruby-recorder'
spec.version = '0.1.0'
version_file = File.expand_path('../../version.txt', __dir__)
spec.version = File.read(version_file).strip
spec.authors = ['Metacraft Labs']
spec.email = ['[email protected]']

Expand Down
9 changes: 4 additions & 5 deletions scripts/publish_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ def ensure_tag_matches_version
tag = ENV['GITHUB_REF_NAME'] || ENV['RELEASE_TAG'] || `git describe --tags --exact-match`.strip
tag = tag.sub(/^v/, '')

native_version = gem_version(File.join('gems', 'native-tracer', 'codetracer-ruby-recorder.gemspec'))
pure_version = gem_version(File.join('gems', 'pure-ruby-tracer', 'codetracer_pure_ruby_recorder.gemspec'))
version = File.read(File.expand_path('../version.txt', __dir__)).strip

unless tag == native_version && tag == pure_version
abort("Tag #{tag} does not match gem versions #{native_version} and #{pure_version}")
unless tag == version
abort("Tag #{tag} does not match gem version #{version}")
end
end

Expand Down Expand Up @@ -59,7 +58,7 @@ def run(cmd, env = {})
FileUtils.rm_f(generic_gem)

# Build and publish pure Ruby gem
run('gem build gems/pure-ruby-tracer/codetracer_pure_ruby_recorder.gemspec')
run('gem build gems/codetracer-pure-ruby-recorder/codetracer_pure_ruby_recorder.gemspec')
pure_gem = Dir['codetracer_pure_ruby_recorder-*.gem'].max_by { |f| File.mtime(f) }
run("gem push #{pure_gem}")
FileUtils.rm_f(pure_gem)
4 changes: 2 additions & 2 deletions test/benchmarks/run_benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run_benchmark(name)
native_dir = File.join(TMP_DIR, name, 'native')
FileUtils.mkdir_p(native_dir)
elapsed = Benchmark.realtime do
system('ruby', File.expand_path('../../gems/native-tracer/lib/native_trace.rb', __dir__),
system('ruby', File.expand_path('../../gems/codetracer-ruby-recorder/lib/native_trace.rb', __dir__),
'--out-dir', native_dir, program)
raise 'Native trace failed' unless $?.success?
end
Expand All @@ -63,7 +63,7 @@ def run_benchmark(name)
pure_dir = File.join(TMP_DIR, name, 'pure')
FileUtils.mkdir_p(pure_dir)
elapsed = Benchmark.realtime do
system('ruby', File.expand_path('../../gems/pure-ruby-tracer/lib/trace.rb', __dir__),
system('ruby', File.expand_path('../../gems/codetracer-pure-ruby-recorder/lib/trace.rb', __dir__),
'--out-dir', pure_dir, program)
raise 'Pure trace failed' unless $?.success?
end
Expand Down
13 changes: 3 additions & 10 deletions test/test_tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def program_args(base)
Dir.glob(File.join(FIXTURE_DIR, '*_trace.json')).each do |fixture|
base = File.basename(fixture, '_trace.json')
define_method("test_#{base}") do
pure_trace, pure_out = run_trace('gems/pure-ruby-tracer/lib/trace.rb', "#{base}.rb", *program_args(base))
native_trace, native_out = run_trace('gems/native-tracer/lib/native_trace.rb', "#{base}.rb", *program_args(base))
pure_trace, pure_out = run_trace('gems/codetracer-pure-ruby-recorder/lib/trace.rb', "#{base}.rb", *program_args(base))
native_trace, native_out = run_trace('gems/codetracer-ruby-recorder/lib/native_trace.rb', "#{base}.rb", *program_args(base))

expected = expected_trace("#{base}.rb")
assert_equal expected, pure_trace
Expand All @@ -64,14 +64,7 @@ def program_args(base)

def run_gem_installation_test(gem_bin, gem_module)
Dir.chdir(File.expand_path('..', __dir__)) do
gem_dir = case gem_bin
when 'codetracer-ruby-recorder'
File.join('gems', 'native-tracer')
when 'codetracer-pure-ruby-recorder'
File.join('gems', 'pure-ruby-tracer')
else
raise ArgumentError, "unknown gem #{gem_bin}"
end
gem_dir = File.join('gems', gem_bin)

if gem_bin == 'codetracer-ruby-recorder'
system('just', 'build-extension', exception: true)
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
Loading