Skip to content

Conversation

@ZeroIntensity
Copy link
Member

@ZeroIntensityZeroIntensity commented May 29, 2025

This is a very rough POC. I think it's important that we don't cause performance regressions here, so I've implemented this alongside the garbage collector.

Does this approach make sense to everyone?

Copy link
Member

@corona10corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you run the pyperformance benchmark first?

@ZeroIntensity
Copy link
MemberAuthor

Sorry for the delay! The pyperformance benchmarks are showing quite a hit in performance:

Benchmarkmain.jsonpatch.jsonChangeSignificance
2to3241 ms271 ms1.13x slowerSignificant (t=-13.56)
async_generators299 ms360 ms1.20x slowerSignificant (t=-20.38)
asyncio_tcp299 ms378 ms1.27x slowerSignificant (t=-40.45)
asyncio_tcp_ssl907 ms1.13 sec1.25x slowerSignificant (t=-40.04)
asyncio_websockets388 ms538 ms1.39x slowerSignificant (t=-116.83)
bench_mp_pool25.3 ms36.5 ms1.44x slowerSignificant (t=-54.78)
bench_thread_pool790 us1.58 ms2.00x slowerSignificant (t=-54.14)
chaos48.6 ms64.7 ms1.33x slowerSignificant (t=-32.61)
comprehensions12.8 us18.5 us1.45x slowerSignificant (t=-68.65)
coroutines16.6 ms27.1 ms1.63x slowerSignificant (t=-7.29)
coverage65.1 ms87.3 ms1.34x slowerSignificant (t=-81.16)
create_gc_cycles784 us1.05 ms1.34x slowerSignificant (t=-138.49)
crypto_pyaes61.7 ms81.0 ms1.31x slowerSignificant (t=-52.46)
deepcopy221 us294 us1.33x slowerSignificant (t=-89.80)
deepcopy_memo23.3 us31.0 us1.33x slowerSignificant (t=-31.68)
deepcopy_reduce2.50 us3.29 us1.32x slowerSignificant (t=-67.66)
deltablue2.65 ms3.54 ms1.33x slowerSignificant (t=-35.96)
docutils1.84 sec2.55 sec1.39x slowerSignificant (t=-26.80)
dulwich_log31.3 ms40.9 ms1.31x slowerSignificant (t=-69.29)
fannkuch292 ms390 ms1.34x slowerSignificant (t=-37.36)
float47.8 ms64.6 ms1.35x slowerSignificant (t=-20.71)
gc_traversal1.66 ms2.10 ms1.26x slowerSignificant (t=-17.49)
generators25.0 ms31.9 ms1.27x slowerSignificant (t=-13.48)
genshi_text20.7 ms27.7 ms1.34x slowerSignificant (t=-69.80)
genshi_xml43.6 ms56.4 ms1.29x slowerSignificant (t=-58.43)
go91.6 ms123 ms1.34x slowerSignificant (t=-80.14)
hexiom4.81 ms6.74 ms1.40x slowerSignificant (t=-67.13)
html5lib39.4 ms52.5 ms1.33x slowerSignificant (t=-28.43)
json_dumps8.00 ms10.7 ms1.33x slowerSignificant (t=-71.96)
json_loads16.2 us22.9 us1.41x slowerSignificant (t=-128.83)
logging_format5.53 us7.43 us1.34x slowerSignificant (t=-72.04)
logging_silent480 ns629 ns1.31x slowerSignificant (t=-55.59)
logging_simple5.09 us6.84 us1.34x slowerSignificant (t=-72.23)
mako8.98 ms11.6 ms1.30x slowerSignificant (t=-67.66)
mdp967 ms1.29 sec1.34x slowerSignificant (t=-45.06)
meteor_contest72.4 ms98.3 ms1.36x slowerSignificant (t=-107.75)
nbody97.1 ms128 ms1.32x slowerSignificant (t=-17.66)
nqueens73.1 ms96.8 ms1.32x slowerSignificant (t=-58.32)
pathlib13.0 ms17.4 ms1.34x slowerSignificant (t=-140.58)
pickle8.12 us10.6 us1.31x slowerSignificant (t=-130.07)
pickle_dict18.0 us23.7 us1.32x slowerSignificant (t=-148.71)
pickle_list2.83 us3.78 us1.33x slowerSignificant (t=-163.84)
pickle_pure_python268 us356 us1.33x slowerSignificant (t=-84.57)
pidigits130 ms173 ms1.33x slowerSignificant (t=-279.46)
pprint_pformat1.38 sec1.90 sec1.37x slowerSignificant (t=-10.28)
pprint_safe_repr683 ms894 ms1.31x slowerSignificant (t=-75.80)
pyflate325 ms447 ms1.37x slowerSignificant (t=-91.12)
python_startup10.1 ms14.1 ms1.40x slowerSignificant (t=-131.69)
python_startup_no_site7.17 ms12.4 ms1.73x slowerSignificant (t=-69.40)
raytrace220 ms297 ms1.35x slowerSignificant (t=-85.28)
regex_compile89.5 ms121 ms1.35x slowerSignificant (t=-122.74)
regex_dna115 ms163 ms1.41x slowerSignificant (t=-92.83)
regex_effbot1.92 ms2.63 ms1.37x slowerSignificant (t=-105.13)
regex_v815.7 ms20.8 ms1.32x slowerSignificant (t=-60.71)
richards36.4 ms48.2 ms1.32x slowerSignificant (t=-55.65)
richards_super42.3 ms57.5 ms1.36x slowerSignificant (t=-45.53)
scimark_fft264 ms339 ms1.28x slowerSignificant (t=-41.68)
scimark_lu92.7 ms123 ms1.32x slowerSignificant (t=-31.12)
scimark_monte_carlo57.8 ms73.7 ms1.28x slowerSignificant (t=-36.04)
scimark_sor90.2 ms122 ms1.36x slowerSignificant (t=-30.54)
scimark_sparse_mat_mult4.71 ms5.89 ms1.25x slowerSignificant (t=-24.55)
spectral_norm82.9 ms103 ms1.25x slowerSignificant (t=-22.27)
sqlglot_normalize228 ms118 ms1.93x fasterSignificant (t=249.63)
sqlglot_optimize41.7 ms55.8 ms1.34x slowerSignificant (t=-91.94)
sqlglot_parse1.04 ms1.38 ms1.32x slowerSignificant (t=-39.12)
sqlglot_transpile1.27 ms1.73 ms1.36x slowerSignificant (t=-43.31)
sqlite_synth1.42 us1.87 us1.32x slowerSignificant (t=-86.85)
telco6.72 ms9.28 ms1.38x slowerSignificant (t=-96.69)
tomli_loads1.73 sec2.18 sec1.26x slowerSignificant (t=-37.94)
typing_runtime_protocols141 us190 us1.35x slowerSignificant (t=-70.98)
unpack_sequence42.2 ns52.4 ns1.24x slowerSignificant (t=-16.62)
unpickle10.7 us14.4 us1.34x slowerSignificant (t=-111.09)
unpickle_list3.41 us4.39 us1.29x slowerSignificant (t=-53.52)
unpickle_pure_python180 us238 us1.32x slowerSignificant (t=-48.67)
xml_etree_generate67.8 ms91.5 ms1.35x slowerSignificant (t=-127.05)
xml_etree_iterparse54.5 ms71.5 ms1.31x slowerSignificant (t=-82.95)
xml_etree_parse83.6 ms113 ms1.35x slowerSignificant (t=-75.07)
xml_etree_process48.3 ms66.8 ms1.38x slowerSignificant (t=-59.14)

Considering this approach is pretty non-intrusive, I suspect automatic DRC just isn't feasible right now, because there will always be false positive "shared" objects no matter how we implement it, and those false positives will experience an apparent 30% hit in performance. I think that individual patches, like #134762, will turn out to work pretty well.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ZeroIntensity@corona10