P403n1x87 / austin

Python frame stack sampler for CPython
https://pypi.org/project/austin-dist/
GNU General Public License v3.0
1.89k stars 54 forks source link

feat: add support for CPython 3.13 #225

Closed P403n1x87 closed 3 weeks ago

P403n1x87 commented 4 months ago

Description of the Change

We add support for CPython 3.13. This new version introduces a data structure designed for easily exposing the required field offsets to out-of-process tools like Austin, via the ABI. We adapt the coding to allow integrating with this new structure.

We currently limit testing to the CPython 3.13 version with the GIL. No testing has currently been done with either the free-threaded version, nor with the new JIT.

Alternate Designs

N.A.

Regressions

There are slim chances that the current approach taken fails under certain circumstances. That is because the new approach would require allocating memory for the Python data structures at runtime, as they are no longer known at compile time. This has been done for some of the more critical structures, but for others we are still relying on the size of the same structures from previous versions. There are no guarantees that this would work.

Verification Process

Existing test suite extended to Python 3.13.

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 78.78788% with 14 lines in your changes missing coverage. Please review.

Project coverage is 69.35%. Comparing base (741d378) to head (05875d0). Report is 2 commits behind head on devel.

Files with missing lines Patch % Lines
src/py_proc.c 73.46% 7 Missing and 6 partials :warning:
src/version.h 90.90% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## devel #225 +/- ## ========================================== + Coverage 68.89% 69.35% +0.46% ========================================== Files 27 27 Lines 2517 2568 +51 Branches 770 787 +17 ========================================== + Hits 1734 1781 +47 - Misses 448 452 +4 Partials 335 335 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 4 months ago

Austin Benchmarks

Running Austin benchmarks with Python 3.10.15

Benchmark Summary

Comparison of dev against 3.6.0.

The following scenarios show a statistically significant difference in performance between the two versions.

Sample Rate Saturation Error Rate Sampling Speed
Wall time [sampling interval: 10] :yellow_circle: :green_circle: :yellow_circle: :yellow_circle:
Multiprocess wall time [sampling interval: 10] :green_circle: :yellow_circle: :yellow_circle: :yellow_circle:
Multiprocess wall time [sampling interval: 100] :yellow_circle: :red_circle: :yellow_circle: :yellow_circle:

Benchmark Results

Wall time [sampling interval: 1] ## Wall time [sampling interval: 1] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 104000 ± 1000 | 1 ± 0 | 1e-05 ± 1e-05 | 14.9 ± 0.6 | | dev | 104000 ± 2000 | 1 ± 0 | 1.7e-05 ± 7e-06 | 14.6 ± 0.7 |
Wall time [sampling interval: 10] ## Wall time [sampling interval: 10] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 100000 ± 4000 | 0.9 ± 0.01 | 1e-05 ± 1e-05 | 15.2 ± 0.4 | | dev | 101000 ± 4000 | 0.85 ± 0.01 | 2.3e-05 ± 9e-06 | 15.2 ± 0.4 |
Wall time [sampling interval: 100] ## Wall time [sampling interval: 100] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 12200 ± 200 | 0.0007 ± 0.0002 | 5e-05 ± 4e-05 | 16.8 ± 0.6 | | dev | 12100 ± 200 | 0.0009 ± 0.0002 | 6e-05 ± 3e-05 | 16.6 ± 0.5 |
Wall time [sampling interval: 1000] ## Wall time [sampling interval: 1000] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 1860 ± 20 | 0 ± 0 | 0.0001 ± 0.0002 | 18 ± 1 | | dev | 1860 ± 40 | 0.0 ± 0.0001 | 0.0 ± 0.0001 | 20 ± 10 |
CPU time [sampling interval: 1] ## CPU time [sampling interval: 1] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 30000 ± 2000 | 1 ± 0 | 5e-05 ± 4e-05 | 27 ± 1 | | dev | 30000 ± 1000 | 1 ± 0 | 7e-05 ± 3e-05 | 27 ± 1 |
CPU time [sampling interval: 10] ## CPU time [sampling interval: 10] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 30000 ± 1000 | 1 ± 0 | 5e-05 ± 4e-05 | 26.8 ± 0.9 | | dev | 30000 ± 1000 | 1 ± 0 | 7e-05 ± 3e-05 | 26.8 ± 0.8 |
CPU time [sampling interval: 100] ## CPU time [sampling interval: 100] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 6310 ± 10 | 0.002 ± 0.001 | 0.0002 ± 0.0001 | 30 ± 1 | | dev | 6310 ± 20 | 0.003 ± 0.001 | 0.0002 ± 0.0001 | 31 ± 1 |
CPU time [sampling interval: 1000] ## CPU time [sampling interval: 1000] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 946 ± 1 | 0 ± 0 | 0.0003 ± 0.0004 | 33 ± 2 | | dev | 946 ± 1 | 0 ± 0 | 0.0001 ± 0.0003 | 34 ± 1 |
RSA keygen [sampling interval: 1] ## RSA keygen [sampling interval: 1] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 32000 ± 2000 | 1 ± 0 | 0.0004 ± 0.0002 | 31 ± 2 | | dev | 30000 ± 2000 | 1 ± 0 | 0.0005 ± 0.0003 | 33 ± 3 |
RSA keygen [sampling interval: 10] ## RSA keygen [sampling interval: 10] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 31000 ± 2000 | 1 ± 0 | 0.0007 ± 0.0006 | 31 ± 3 | | dev | 30000 ± 3000 | 1 ± 0 | 0.0005 ± 0.0003 | 33 ± 4 |
RSA keygen [sampling interval: 100] ## RSA keygen [sampling interval: 100] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 6310 ± 20 | 0.02 ± 0.02 | 0.002 ± 0.001 | 36 ± 3 | | dev | 6320 ± 40 | 0.03 ± 0.04 | 0.002 ± 0.002 | 39 ± 7 |
RSA keygen [sampling interval: 1000] ## RSA keygen [sampling interval: 1000] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 943.3 ± 0.5 | 0 ± 0 | 0.004 ± 0.004 | 38 ± 2 | | dev | 942 ± 2 | 0 ± 0 | 0.002 ± 0.003 | 40 ± 6 |
Full metrics [sampling interval: 1] ## Full metrics [sampling interval: 1] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 39400 ± 800 | 1 ± 0 | 5e-05 ± 3e-05 | 38.4 ± 0.7 | | dev | 39100 ± 700 | 1 ± 0 | 7e-05 ± 3e-05 | 38.4 ± 0.8 |
Full metrics [sampling interval: 10] ## Full metrics [sampling interval: 10] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 39000 ± 1000 | 1 ± 0 | 4e-05 ± 4e-05 | 38.4 ± 0.5 | | dev | 39200 ± 900 | 1 ± 0 | 6e-05 ± 3e-05 | 38.4 ± 0.8 |
Full metrics [sampling interval: 100] ## Full metrics [sampling interval: 100] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 12200 ± 200 | 0.004 ± 0.0008 | 0.00012 ± 3e-05 | 44 ± 1 | | dev | 12200 ± 300 | 0.005 ± 0.001 | 0.0002 ± 0.0001 | 44.4 ± 1.0 |
Full metrics [sampling interval: 1000] ## Full metrics [sampling interval: 1000] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 1850 ± 30 | 0 ± 0 | 0.0002 ± 0.0002 | 48 ± 2 | | dev | 1850 ± 30 | 0 ± 0 | 0.0003 ± 0.0003 | 48 ± 1 |
Multiprocess wall time [sampling interval: 1] ## Multiprocess wall time [sampling interval: 1] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 3800 ± 500 | 1 ± 0 | 0.0002 ± 0.0001 | 230 ± 30 | | dev | 4100 ± 200 | 1 ± 0 | 0.00026 ± 5e-05 | 230 ± 9 |
Multiprocess wall time [sampling interval: 10] ## Multiprocess wall time [sampling interval: 10] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 3600 ± 700 | 1 ± 0 | 0.0002 ± 0.0001 | 232 ± 10 | | dev | 4200 ± 300 | 1 ± 0 | 0.0003 ± 7e-05 | 220 ± 10 |
Multiprocess wall time [sampling interval: 100] ## Multiprocess wall time [sampling interval: 100] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 3900 ± 400 | 0.034 ± 0.004 | 0.0002 ± 8e-05 | 234 ± 10 | | dev | 3940 ± 80 | 0.038 ± 0.003 | 0.00027 ± 6e-05 | 240 ± 5 |
Multiprocess wall time [sampling interval: 1000] ## Multiprocess wall time [sampling interval: 1000] | | Sample Rate | Saturation | Error Rate | Sampling Speed | | --- |:-----------:|:----------:|:----------:|:--------------:| | 3.6.0 | 3700 ± 300 | 0.008 ± 0.005 | 5e-05 ± 2e-05 | 110 ± 40 | | dev | 3830 ± 60 | 0.0059 ± 0.0007 | 5e-05 ± 6e-05 | 90 ± 3 |