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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -20,6 +20,10 @@ shards:
git: https://github.com/84codes/mqtt-protocol.cr.git
version: 0.2.0+git.commit.3f82ee85d029e6d0505cbe261b108e156df4e598

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

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 @@ -38,6 +38,8 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
perf_tools:
github: crystal-lang/perf-tools

crystal: 1.15.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 @@ -202,9 +206,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to log as well

{% 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output from log_fibers

4
/usr/lib/crystal/crystal/system/unix/signal.cr:99:7 in 'process'
/usr/lib/crystal/crystal/system/unix/signal.cr:87:9 in '->'
/usr/lib/crystal/fiber.cr:148:11 in 'run'
/usr/lib/crystal/fiber.cr:100:34 in '->'

....

what does it mean and is it worth to have in the output?

{% end %}
STDOUT.flush
end

Expand Down
Loading