xpra icon
Bug tracker and wiki

Changes between Version 13 and Version 14 of Profiling


Ignore:
Timestamp:
12/11/13 10:26:02 (6 years ago)
Author:
Antoine Martin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Profiling

    v13 v14  
     1{{{#!div class="box"
    12= Profiling =
    23
     
    45[[BR]]
    56[/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}}}
    68
     9
     10{{{#!div class="box"
    711== cProfile ==
    812[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:
     
    2832(...)
    2933}}}
     34}}}
    3035
     36
     37{{{#!div class="box"
    3138== pycallgraph ==
    3239
     
    5360* some [../Debugging Debugging] environment variables may be useful
    5461* save useful graphs with all the information relating to the version used, modifications, environment, etc. So these can be reproduced later.
     62}}}
    5563
    56 
     64{{{#!div class="box"
    5765== Fixing Bottlenecks ==
    5866First, write a test to measure/isolate the problematic part of the code.
     
    6472* better algorithms
    6573
    66 [[BR]]
     74
    6775----
    68 [[BR]]
    6976
    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
     77You can find a detailed example of how Cython was used to eliminate a performance bottleneck here: [/wiki/Profiling/Examples]
    8478}}}
    85 * After:
    86 {{{
    87 $ XPRA_CYTHON_MATH=1 ./tests/xpra/test_maths.py
    88 calculate_time_weighted_average(100000 records)=(0.5226684212684631, 0.5245391130447388)
    89 elapsed time: 4.0ms
    90 test_calculate_timesize_weighted_average(100000 records)=(180154.15625, 35980.69140625)
    91 elapsed time: 19.7ms
    92 }}}
    93 Which is 10 to 20 times faster.
    94 
    95 == high network cost in UI thread ==
    96 Work in progress, see #231
    97 
    98 == high cost of logging ==
    99 This is a recurring problem, see: r2294, r2290, etc
    100 
    101 By running the server with:
    102 {{{
    103 xpra start :10 --start-child=glxgears
    104 }}}
    105 And the client with:
    106 {{{
    107 ./tests/scripts/pycallgraph -t draw -i '*' -r 20 -- attach :10 --no-mmap
    108 }}}
    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!