• NodeBB

    Start nodebb with

    NODE_ENV=production node --prof app.js

    Generate some load with

    ab -n 10000 -c 1 http://127.0.0.1:4567/<url_to_load_test>

    There should be a file created in your nodebb folder that looks like isolate-*-v8.log. Process this file to make it human readable with

    node --prof-process isolate-*-v8.log > processed.txt

    If you want to generate flame graphs you can use this instead.

    node --prof-process --preprocess -j isolate-*-v8.log > v8.json and upload it to https://mapbox.github.io/flamebearer/#0,3 which will give you this

    2ca8a665-6deb-4f3c-88a1-5c010e7b0dd4-image.png

    Sample output from processed file

    Statistical profiling result from isolate-*-v8.log, (26321 ticks, 51 unaccounted, 0 excluded).
    
     [Shared libraries]:
       ticks  total  nonlib   name
      19741   75.0%          C:\WINDOWS\SYSTEM32\ntdll.dll
       5300   20.1%          C:\Program Files\nodejs\node.exe
         20    0.1%          C:\WINDOWS\System32\KERNELBASE.dll
         10    0.0%          C:\WINDOWS\System32\WS2_32.dll
          7    0.0%          C:\WINDOWS\system32\mswsock.dll
          7    0.0%          C:\WINDOWS\System32\KERNEL32.DLL
    
     [JavaScript]:
       ticks  total  nonlib   name
         75    0.3%    6.1%  LazyCompile: *translate C:\Users\Baris\Desktop\github\nodebb_master\public\src\modules\translator.js:86:54
         45    0.2%    3.6%  LazyCompile: *next C:\Users\Baris\Desktop\github\nodebb_master\node_modules\express\lib\router\index.js:176:16
         42    0.2%    3.4%  LazyCompile: *<anonymous> :3:20100
         35    0.1%    2.8%  RegExp: &rsqb;|\\]
         27    0.1%    2.2%  RegExp: &lsqb;|\\[
         22    0.1%    1.8%  LazyCompile: *<anonymous> :3:22441
         21    0.1%    1.7%  LazyCompile: *module.getObjectsFields C:\Users\Baris\Desktop\github\nodebb_master\src\database\mongo\hash.js:83:43
         17    0.1%    1.4%  LazyCompile: *serializeInto C:\Users\Baris\Desktop\github\nodebb_master\node_modules\bson\lib\bson\parser\serializer.js:674:43
         15    0.1%    1.2%  LazyCompile: *Plugins.fireHook C:\Users\Baris\Desktop\github\nodebb_master\src\plugins\hooks.js:87:36
         14    0.1%    1.1%  LazyCompile: *getTopic C:\Users\Baris\Desktop\github\nodebb_master\src\controllers\topics.js:21:47
         14    0.1%    1.1%  LazyCompile: *baseClone C:\Users\Baris\Desktop\github\nodebb_master\node_modules\lodash\lodash.js:2620:23
         13    0.0%    1.1%  LazyCompile: *deserializeObject C:\Users\Baris\Desktop\github\nodebb_master\node_modules\bson\lib\bson\parser\deserializer.js:43:33
         13    0.0%    1.1%  LazyCompile: *addTags C:\Users\Baris\Desktop\github\nodebb_master\src\controllers\topics.js:165:23
         11    0.0%    0.9%  LazyCompile: *Groups.isMemberOfGroups C:\Users\Baris\Desktop\github\nodebb_master\src\groups\membership.js:67:43
         10    0.0%    0.8%  LazyCompile: *onStreamRead internal/stream_base_commons.js:165:22
          9    0.0%    0.7%  LazyCompile: *wrapperCallback C:\Users\Baris\Desktop\github\nodebb_master\src\promisify.js:40:40
          9    0.0%    0.7%  LazyCompile: *fireActionHook C:\Users\Baris\Desktop\github\nodebb_master\src\plugins\hooks.js:130:31
          9    0.0%    0.7%  LazyCompile: *apiController.loadConfig C:\Users\Baris\Desktop\github\nodebb_master\src\controllers\api.js:24:43
          9    0.0%    0.7%  LazyCompile: *User.getUsersFields C:\Users\Baris\Desktop\github\nodebb_master\src\user\data.js:51:39
          9    0.0%    0.7%  LazyCompile: *Tags.parse C:\Users\Baris\Desktop\github\nodebb_master\src\meta\tags.js:16:14
          9    0.0%    0.7%  LazyCompile: *<anonymous> C:\Users\Baris\Desktop\github\nodebb_master\node_modules\mongodb\lib\collection.js:323:11
          8    0.0%    0.6%  RegExp: [^a-zA-Z0-9\-_.\/]]
    ...
    
  • Community Rep

    @baris Good stuff! πŸ‘

    Flame graphs - not just for Solaris anymore. Hip, hip, hooray for portable software engineering. 🀸

    Those interested in a bit deeper dive may want to check out Brendan Gregg's blog.

Suggested Topics

  • 1
  • 6
  • 25
  • 9
  • 5
| |