| 1 | = Profiling Examples = |
| 2 | |
| 3 | {{{#!div class="box" |
| 4 | == maths.py re-written in Cython == |
| 5 | Merged in r2462 |
| 6 | |
| 7 | [[BR]] |
| 8 | |
| 9 | * Before: |
| 10 | {{{ |
| 11 | $ XPRA_CYTHON_MATH=0 ./tests/xpra/test_maths.py |
| 12 | calculate_time_weighted_average(100000 records)=(0.5129547191923681, 0.529864013016996) |
| 13 | elapsed time: 72.6ms |
| 14 | test_calculate_timesize_weighted_average(100000 records)=(70109.42497899215, 22337.16293859974) |
| 15 | elapsed time: 204.9ms |
| 16 | }}} |
| 17 | * After: |
| 18 | {{{ |
| 19 | $ XPRA_CYTHON_MATH=1 ./tests/xpra/test_maths.py |
| 20 | calculate_time_weighted_average(100000 records)=(0.5226684212684631, 0.5245391130447388) |
| 21 | elapsed time: 4.0ms |
| 22 | test_calculate_timesize_weighted_average(100000 records)=(180154.15625, 35980.69140625) |
| 23 | elapsed time: 19.7ms |
| 24 | }}} |
| 25 | Which is 10 to 20 times faster. |
| 26 | }}} |
| 27 | |
| 28 | {{{#!div class="box" |
| 29 | == high network cost in UI thread == |
| 30 | Work in progress, see #231 |
| 31 | }}} |
| 32 | |
| 33 | {{{#!div class="box" |
| 34 | == Fixing an expensive logging call (in a hotpath) == |
| 35 | This is a recurring problem, see: r2294, r2290, etc |
| 36 | |
| 37 | By running the server with: |
| 38 | {{{ |
| 39 | xpra start :10 --start-child=glxgears |
| 40 | }}} |
| 41 | And the client with: |
| 42 | {{{ |
| 43 | ./tests/scripts/pycallgraph -t draw -i '*' -r 20 -- attach :10 --no-mmap |
| 44 | }}} |
| 45 | We find that logging is really costing us dearly: |
| 46 | [[BR]] |
| 47 | [[Image(pycallgraph-draw-loggingisexpensive.png)]] |
| 48 | [[BR]] |
| 49 | So we remove logging from this critical path in r2484, and we now find: |
| 50 | [[BR]] |
| 51 | [[Image(pycallgraph-draw-loggingremoved.png)]] |
| 52 | [[BR]] |
| 53 | That's a saving of about 35% - not bad for such a small change! |
| 54 | }}} |