vyos-1x
vyos-1x copied to clipboard
validators: T4472: Add validator ipv4-range-go in golang
Change Summary
Go validators decrease the validation time to compares with
bash + ipaddrcheck --something or python3
As PoC we decrease the validation time for ipv4-range
(10K checks)
from 48 seconds to 27 seconds
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes)
- [ ] Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
- [x] Other (please describe):
Related Task(s)
- https://phabricator.vyos.net/T4472
Component(s) name
Proposed changes
How to test
Check validations:
Standard ipv4-range
vyos@r14# time sudo sh -c ' for ((n=0;n<10000;n++)); do /usr/libexec/vyos/validate-value --exec /usr/libexec/vyos/validators/ipv4-range --value "192.0.2.1-192.0.2.100"; done'
real 0m48.825s
user 0m26.534s
sys 0m23.904s
[edit]
vyos@r14#
The same validator in go
vyos@r14# time sudo sh -c ' for ((n=0;n<10000;n++)); do /usr/libexec/vyos/validate-value --exec /usr/libexec/vyos/validators/ipv4-range-go --value "192.0.2.1-192.0.2.100"; done'
real 0m27.069s
user 0m12.814s
sys 0m14.784s
[edit]
vyos@r14#
Checklist:
- [x] I have read the CONTRIBUTING document
- [x] I have linked this PR to one or more Phabricator Task(s)
- [ ] I have run the components SMOKETESTS if applicable
- [x] My commit headlines contain a valid Task id
- [ ] My change requires a change to the documentation
- [ ] I have updated the documentation accordingly
Your approach requires adding a golang dependency
We already have golang in vyos-build So it doesn’t require any additional package
Close it, the original issue was solved, but we agree that it could be a good experience for the next validators