vyos-1x icon indicating copy to clipboard operation
vyos-1x copied to clipboard

validators: T4472: Add validator ipv4-range-go in golang

Open sever-sever opened this issue 2 years ago • 1 comments

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

sever-sever avatar Jun 19 '22 11:06 sever-sever

Your approach requires adding a golang dependency

We already have golang in vyos-build So it doesn’t require any additional package

sever-sever avatar Jun 25 '22 17:06 sever-sever

Close it, the original issue was solved, but we agree that it could be a good experience for the next validators

sever-sever avatar Sep 01 '22 15:09 sever-sever