austin icon indicating copy to clipboard operation
austin copied to clipboard

perf: cache string objects

Open P403n1x87 opened this issue 2 years ago • 2 comments

Description of the Change

Some strings my be shared across code objects and therefore it makes sense to store them in a cache for faster access.

Alternate Designs

N.A.

Regressions

We expect string objects attached to code object to live as long as the latter, so that addresses are not reused for different string objects.

Verification Process

Existing test suite.

P403n1x87 avatar Jul 19 '22 14:07 P403n1x87

Codecov Report

Base: 69.75% // Head: 70.32% // Increases project coverage by +0.56% :tada:

Coverage data is based on head (6acd13a) compared to base (a633faf). Patch coverage: 88.23% of modified lines in pull request are covered.

:exclamation: Current head 6acd13a differs from pull request most recent head d35fcf1. Consider uploading reports for the commit d35fcf1 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #126      +/-   ##
==========================================
+ Coverage   69.75%   70.32%   +0.56%     
==========================================
  Files          23       23              
  Lines        2394     2433      +39     
  Branches      697      707      +10     
==========================================
+ Hits         1670     1711      +41     
+ Misses        403      400       -3     
- Partials      321      322       +1     
Impacted Files Coverage Δ
src/mojo.h 100.00% <ø> (ø)
src/py_proc.c 63.31% <33.33%> (-0.52%) :arrow_down:
src/stack.h 86.27% <89.47%> (+6.27%) :arrow_up:
src/py_string.h 74.39% <90.00%> (+3.87%) :arrow_up:
src/py_thread.c 74.53% <96.42%> (+1.62%) :arrow_up:
src/cache.c 85.31% <100.00%> (ø)
src/linux/py_proc.h 55.63% <0.00%> (-2.16%) :arrow_down:
src/argparse.c 62.00% <0.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jul 19 '22 14:07 codecov[bot]

Benchmarking figures don't show any major improvements so we hold merging this PR for now.

P403n1x87 avatar Sep 14 '22 09:09 P403n1x87

Latest benchmarking figures

RSA keygen [sampling interval: 1]
=================================================================
        Sample Rate  Saturation    Error Rate     Sampling Speed 
-----------------------------------------------------------------
 3.0.0  12200 ± 400    1 ± 0     0.0002 ± 0.0002      81 ± 2     
 3.1.0  12100 ± 500    1 ± 0     0.0004 ± 0.0005      82 ± 3     
 3.2.0  11000 ± 300    1 ± 0      0.002 ± 0.001       91 ± 3     
 3.3.0  45900 ± 400    1 ± 0     0.0004 ± 0.0002    21.1 ± 0.3   
  dev   46000 ± 600    1 ± 0     0.0007 ± 0.0005    21.1 ± 0.3   
=================================================================

RSA keygen [sampling interval: 10]
====================================================================
        Sample Rate   Saturation      Error Rate     Sampling Speed 
--------------------------------------------------------------------
 3.0.0  11680 ± 90    0.97 ± 0.02   0.0004 ± 0.0004      84 ± 1     
 3.1.0  11900 ± 200   0.95 ± 0.03   0.0002 ± 0.0002      84 ± 2     
 3.2.0  10700 ± 200   0.94 ± 0.04    0.002 ± 0.001       92 ± 2     
 3.3.0  45600 ± 400  0.989 ± 0.008  0.0004 ± 0.0002    21.2 ± 0.4   
  dev   45600 ± 800   0.98 ± 0.01   0.0005 ± 0.0004    21.2 ± 0.4   
====================================================================

RSA keygen [sampling interval: 100]
======================================================================
        Sample Rate    Saturation       Error Rate     Sampling Speed 
----------------------------------------------------------------------
 3.0.0   6510 ± 70     0.07 ± 0.02    0.0001 ± 0.0001      90 ± 2     
 3.1.0   6550 ± 20     0.06 ± 0.01    0.0001 ± 0.0001    88.9 ± 1.0   
 3.2.0   6670 ± 90     0.12 ± 0.06     0.003 ± 0.002       99 ± 2     
 3.3.0   6490 ± 30    0.002 ± 0.001    0.001 ± 0.001       24 ± 1     
  dev    6505 ± 9    0.0007 ± 0.0006  0.001 ± 0.0004     23.5 ± 0.5   
======================================================================

RSA keygen [sampling interval: 1000]
=================================================================
        Sample Rate  Saturation    Error Rate     Sampling Speed 
-----------------------------------------------------------------
 3.0.0    924 ± 2      0 ± 0      0.001 ± 0.001      103 ± 2     
 3.1.0    923 ± 1      0 ± 0     0.0002 ± 0.0005     102 ± 1     
 3.2.0    923 ± 2      0 ± 0      0.003 ± 0.005      114 ± 6     
 3.3.0    923 ± 2      0 ± 0      0.002 ± 0.003       38 ± 3     
  dev     923 ± 2      0 ± 0      0.001 ± 0.002       36 ± 2     
=================================================================

There doesn't seem to be much performance gain in terms of sampling. But the main benefit is in the smaller size of generated Mojo files:

-rw-rw-r-- 1 gabriele gabriele 1.9M Oct 15 16:14 /tmp/cache.mojo
-rw-rw-r-- 1 gabriele gabriele 3.3M Oct 15 16:14 /tmp/devel.mojo

P403n1x87 avatar Oct 15 '22 15:10 P403n1x87