Benchmark acquirespecificip to nail down performance problems #147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#146 shows that ip allocation in prefixes with a lot of already allocated ips is slow.
This PR implements a Benchmark which shows this clearly:
looking at the cpu profile, we can see that most of the time is spent in the deepcopy function of a prefix.
This is the cpu profile running this benchmark with an empty prefix:
![empty-prefix](https://private-user-images.githubusercontent.com/410110/329763939-6ab6d169-3323-42a9-915b-d0a02475a510.svg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyODIzMTQsIm5iZiI6MTcyMDI4MjAxNCwicGF0aCI6Ii80MTAxMTAvMzI5NzYzOTM5LTZhYjZkMTY5LTMzMjMtNDJhOS05MTViLWQwYTAyNDc1YTUxMC5zdmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNlQxNjA2NTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mYzY4ZjU3OTMzZjkwZjFlOTU5MGNkZTExYmM0MTEyMGE2NDIxMWFlYjE0YTU4YzA1OTc1ODJiMzIwYTMxNGYzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.i2jRB74sfYDQu0-ZJPsRBpz5hkDT2l3fJBTSPOQcyps)
And this shows the cpu profile with 5000 already allocated ips:
![fivethousend-ips-allocated](https://private-user-images.githubusercontent.com/410110/329764007-e85a9880-43d7-4d2b-8db9-f15d13d0fcff.svg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyODIzMTQsIm5iZiI6MTcyMDI4MjAxNCwicGF0aCI6Ii80MTAxMTAvMzI5NzY0MDA3LWU4NWE5ODgwLTQzZDctNGQyYi04ZGI5LWYxNWQxM2QwZmNmZi5zdmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNlQxNjA2NTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05MGFmOTc5Y2I2ODYwYjNlYzZlOGFkZDZiYjU0OGEyNjZjNWUyNGNkMzk2MDJjZmYxYmViNTAwNDAxMjdkMTg2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.9tybJlh2uCpcjT4ItWXDcEE_V6EWXwFLa3mtn0yL9JU)
Graphs are generated with: