| 48 | * save useful graphs with all the information relating to the version used, modifications, environment, etc. So these can be reproduced later. |
| 49 | |
| 50 | |
| 51 | == Fixing Bottlenecks == |
| 52 | First, write a test to measure/isolate the problematic part of the code. |
| 53 | [[BR]] |
| 54 | There are no magic solutions to apply, some common solutions: |
| 55 | * threading (we already have too many threads though..) |
| 56 | * re-writing in C or Cython |
| 57 | * better algorithms |
| 58 | |
| 59 | |
| 60 | == Examples == |
| 61 | |
| 62 | === maths.py re-written in Cython === |
| 63 | Merged in r2462 |
| 64 | |
| 65 | [[BR]] |
| 66 | |
| 67 | * Before: |
| 68 | {{{ |
| 69 | $ XPRA_CYTHON_MATH=0 ./tests/xpra/test_maths.py |
| 70 | calculate_time_weighted_average(100000 records)=(0.5129547191923681, 0.529864013016996) |
| 71 | elapsed time: 72.6ms |
| 72 | test_calculate_timesize_weighted_average(100000 records)=(70109.42497899215, 22337.16293859974) |
| 73 | elapsed time: 204.9ms |
| 74 | }}} |
| 75 | * After: |
| 76 | {{{ |
| 77 | $ XPRA_CYTHON_MATH=1 ./tests/xpra/test_maths.py |
| 78 | calculate_time_weighted_average(100000 records)=(0.5226684212684631, 0.5245391130447388) |
| 79 | elapsed time: 4.0ms |
| 80 | test_calculate_timesize_weighted_average(100000 records)=(180154.15625, 35980.69140625) |
| 81 | elapsed time: 19.7ms |
| 82 | }}} |
| 83 | Which is 10 to 20 times faster. |