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

Use perf-tools for allocations/fiber tracking #733

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ shards:
git: https://github.com/84codes/lz4.cr.git
version: 1.0.0+git.commit.96d714f7593c66ca7425872fd26c7b1286806d3d

perf_tools:
git: https://github.com/crystal-lang/perf-tools.git
version: 0.1.0+git.commit.72f0956c9edfb2a67d4eb18e134a34c711a9d94a

systemd:
git: https://github.com/84codes/systemd.cr.git
version: 2.0.0
Expand Down
2 changes: 2 additions & 0 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
perf_tools:
github: crystal-lang/perf-tools

crystal: 1.13.0

Expand Down
20 changes: 17 additions & 3 deletions src/lavinmq/launcher.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% unless flag?(:release) %}
require "perf_tools/mem_prof"
require "perf_tools/fiber_trace"
{% end %}
require "log"
require "file"
require "systemd"
Expand Down Expand Up @@ -165,9 +169,19 @@ module LavinMQ
puts " marker threads: #{ps.markers_m1}"
puts " reclaimed bytes during last GC: #{ps.bytes_reclaimed_since_gc.humanize_bytes}"
puts " reclaimed bytes before last GC: #{ps.reclaimed_bytes_before_gc.humanize_bytes}"
puts "Fibers:"
Fiber.list { |f| puts f.inspect }
LavinMQ::Reporter.report(@amqp_server)
# puts "Fibers:"
# Fiber.list { |f| puts f.inspect }
# LavinMQ::Reporter.report(@amqp_server)
{% unless flag?(:release) %}
puts "Object counts:"
PerfTools::MemProf.log_object_counts(STDOUT)
puts "Object sizes:"
PerfTools::MemProf.log_object_sizes(STDOUT)
puts "Allocations:"
PerfTools::MemProf.log_allocations(STDOUT)
puts "Fibers:"
PerfTools::FiberTrace.log_fibers(STDOUT)
{% end %}
STDOUT.flush
end

Expand Down
Loading