Permalink
Browse files

Fix script/stackprof & add some GC stats.

When running 'script/stackprof object', I noticed that it would be helpful to see
GC information. It appears we create a lot of junk -- a source of optimization if
we decide to go down that path.

An average Jekyll build doesn't run a GC, but auto-regeneration likely would eventually
require a GC run and it would be interesting to see if we can reduce how much we throw
away with each call to 'site.process'.
  • Loading branch information...
1 parent 52c2645 commit 1bc82b9c8a28e2170e3ac256dde01b4cf265e016 @parkr parkr committed Dec 29, 2016
Showing with 8 additions and 4 deletions.
  1. +8 −4 script/stackprof
View
@@ -10,13 +10,17 @@ esac
export BENCHMARK=true
command -v stackprof > /dev/null || script/bootstrap
-TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site'})"
+TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'docs'})"
PROF_OUTPUT_FILE=tmp/stackprof-${STACKPROF_MODE}-$(date +%Y%m%d%H%M).dump
+GC_BEFORE="puts 'GC Stats:'; puts JSON.pretty_generate(GC.stat); GC.disable"
+GC_AFTER="puts 'GC Stats:'; GC.start(full_mark: true, immediate_sweep: false); puts JSON.pretty_generate(GC.stat);"
+
echo Stackprof Mode: $STACKPROF_MODE
test -f "$PROF_OUTPUT_FILE" || {
- bundle exec ruby -r./lib/jekyll -rstackprof \
- -e "StackProf.run(mode: :${STACKPROF_MODE}, interval: 100, out: '${PROF_OUTPUT_FILE}') { ${TEST_SCRIPT} }"
+ bundle exec ruby -r./lib/jekyll -rstackprof -rjson \
+ -e "StackProf.run(mode: :${STACKPROF_MODE}, interval: 100, out: '${PROF_OUTPUT_FILE}') { ${GC_BEFORE}; ${TEST_SCRIPT}; ${GC_AFTER}; }"
}
-bundle exec stackprof $PROF_OUTPUT_FILE $@
+set -x
+bundle exec stackprof $PROF_OUTPUT_FILE $@ --sort-total

0 comments on commit 1bc82b9

Please sign in to comment.