Changes between Version 13 and Version 14 of Profiling
- Timestamp:
- 12/11/13 10:26:02 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Profiling
v13 v14 1 {{{#!div class="box" 1 2 = Profiling = 2 3 … … 4 5 [[BR]] 5 6 [/wiki/WindowRefresh Window Refresh] speed is a special case as it depends on many factors and not just pure code performance, though some parts of this code can obviously benefit from profiling. 7 }}} 6 8 9 10 {{{#!div class="box" 7 11 == cProfile == 8 12 [http://docs.python.org/2/library/profile.html#module-cProfile cProfile] outputs text only, which may be more appropriate in some cases. Simply replace {{{xpra}}} with {{{tests/scripts/cProfile}}} on the command line: … … 28 32 (...) 29 33 }}} 34 }}} 30 35 36 37 {{{#!div class="box" 31 38 == pycallgraph == 32 39 … … 53 60 * some [../Debugging Debugging] environment variables may be useful 54 61 * save useful graphs with all the information relating to the version used, modifications, environment, etc. So these can be reproduced later. 62 }}} 55 63 56 64 {{{#!div class="box" 57 65 == Fixing Bottlenecks == 58 66 First, write a test to measure/isolate the problematic part of the code. … … 64 72 * better algorithms 65 73 66 [[BR]] 74 67 75 ---- 68 [[BR]]69 76 70 = Examples = 71 72 == maths.py re-written in Cython == 73 Merged in r2462 74 75 [[BR]] 76 77 * Before: 78 {{{ 79 $ XPRA_CYTHON_MATH=0 ./tests/xpra/test_maths.py 80 calculate_time_weighted_average(100000 records)=(0.5129547191923681, 0.529864013016996) 81 elapsed time: 72.6ms 82 test_calculate_timesize_weighted_average(100000 records)=(70109.42497899215, 22337.16293859974) 83 elapsed time: 204.9ms 77 You can find a detailed example of how Cython was used to eliminate a performance bottleneck here: [/wiki/Profiling/Examples] 84 78 }}} 85 * After:86 {{{87 $ XPRA_CYTHON_MATH=1 ./tests/xpra/test_maths.py88 calculate_time_weighted_average(100000 records)=(0.5226684212684631, 0.5245391130447388)89 elapsed time: 4.0ms90 test_calculate_timesize_weighted_average(100000 records)=(180154.15625, 35980.69140625)91 elapsed time: 19.7ms92 }}}93 Which is 10 to 20 times faster.94 95 == high network cost in UI thread ==96 Work in progress, see #23197 98 == high cost of logging ==99 This is a recurring problem, see: r2294, r2290, etc100 101 By running the server with:102 {{{103 xpra start :10 --start-child=glxgears104 }}}105 And the client with:106 {{{107 ./tests/scripts/pycallgraph -t draw -i '*' -r 20 -- attach :10 --no-mmap108 }}}109 We find that logging is really costing us dearly:110 [[BR]]111 [[Image(pycallgraph-draw-loggingisexpensive.png)]]112 [[BR]]113 So we remove logging from this critical path in r2484, and we now find:114 [[BR]]115 [[Image(pycallgraph-draw-loggingremoved.png)]]116 [[BR]]117 That's a saving of about 35% - not bad for such a small change!