MarshalX / python-libipld

๐ŸŽ๏ธ Fast Python library to work with IPLD: DAG-CBOR, CID, CAR, multibase
https://pypi.org/project/libipld/
MIT License
17 stars 2 forks source link

Optimize array creation #40

Closed MarshalX closed 8 months ago

codspeed-hq[bot] commented 8 months ago

CodSpeed Performance Report

Merging #40 will degrade performances by 12.26%

Comparing optimize-array-creation (6d428c8) with main (9fb1353)

Summary

โšก 1 improvements โŒ 1 (๐Ÿ‘ 1) regressions โœ… 190 untouched benchmarks

Benchmarks breakdown

Benchmark main optimize-array-creation Change
๐Ÿ‘ test_dag_cbor_decode_fixtures[dagpb_simple_forms_3] 69.8 ยตs 79.6 ยตs -12.26%
โšก test_dag_cbor_decode_real_data[canada.json] 399.9 ms 344.8 ms +15.97%
davidhewitt commented 8 months ago

I guess PyList::new didn't work for you because the iteration produces fallible elements? I wonder if we can work to improve that...

MarshalX commented 8 months ago

@davidhewitt here is the flamegraph of append before this PR:

image

is list resizing is fast in python btw? i mean resizing (with append) vs not resizing (with SET_ITEM)

davidhewitt commented 8 months ago

I think resizing will always be slow, so it makes sense that this was a bottleneck. I will try to use this example to add weight to my suggestions for the CPython team ๐Ÿ˜‚