You are reading content from Scuttlebutt
@Anders %3+jTw8MTBKHgBQyfMzyo0rNeQ5uRiyMb6N2dgzKMSfo=.sha256
Re: %j4opufqPR

I'll bite, I know this hasn't been granted, but as I said before. Profiling is a fun sport for me :smiley:

I wanted to try and run a full profile of my sbot to see if there was anything sticking out. I've done some profiling of C++ code before and valgrind was quite nice there, so I fired up node --profile bin.js server. Let it shift through messages from tonight and got a profile. Got the information on profiling from here. One of the top offenders was:

4213 4.0% 4.1% LazyCompile: *module.exports /home/chrx/dev/scuttlebot/node_modules/epidemic-broadcast-trees/progress.js:45:27

Which is a bit odd for me. Don't mind the LazyCompile. The * means that the code has been optimized. But 4213 calls seems like a lot (it was running for max 5 minutes). I havn't looked at the epidemic broadcast tree code before. The progress.js is rather innocent, so its were its called that is the problem. index.js calls it in two places:

var onChange = opts.onChange || require('./bounce')(function () {
  console.log(progress(states))
}, 1000)

and

  progress: function () {
    return progress(states)
  },

So I added a console.log to the second one, as the first is decounced, to see and that function seems to be called around every 100ms or more after connecting to a peer. I guess that is a bit excessive?

Join Scuttlebutt now