-
Notifications
You must be signed in to change notification settings - Fork 297
xapi-stdext-std: remove most functions, optimize escaping functions #6795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Users can instead opt for Astring.String's or stdlib's functions. Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
Also remove all indiscriminate opens against it Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
b897cff to
1b21740
Compare
|
I'll run some system tests on this and have a proper look throughout the day. |
|
Has |
String.replaced is an alias of map_unlikely. This names makes the intent
of the function clearer. Because a function to replace the characters is
exposed, users are less likely to fall into the pitfall of using lists.
Lists not only are very slow, but allow users to have more than one
replacement rule per character, possibly introducing mistakes.
If a plain match function cannot be produced and a list needs to be used,
users can convert it to a Char.Map and do the match with a find_opt.
This approach ends up being ~60-70% faster than using plain lists.
The benchmark comparing the new approach with the old one:
String size 100:
Optimized: 236.556 μs
Reference: 1861.600 μs
Improvement: 87.3% faster
String size 500:
Optimized: 1099.030 μs
Reference: 9665.405 μs
Improvement: 88.6% faster
String size 1000:
Optimized: 2198.777 μs
Reference: 19115.019 μs
Improvement: 88.5% faster
Signed-off-by: Pau Ruiz Safont <[email protected]>
Not only it's more efficient, but it's also more ergonomic Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
The former didn't have any tests and the performance is unknown Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
This also allows to drop String.isspace Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
The few users that needed to replace strings, have been replaced with Astring's cuts, as most of them were already segmenting strings, or they are run in very specific, infrequent codepaths for efficiency to not matter. Others have been replaced by Astring's filter as they were removing characters, and the rest have been converted to the new String.replace. map_unlikely can be removed from the interface and only have String.replaced and String.replace Signed-off-by: Pau Ruiz Safont <[email protected]> Signed-off-by: Pau Ruiz Safont <[email protected]>
1b21740 to
aebedca
Compare
|
Yes, from the message of the commit that introduces it (1174f3a): It can also be easily run with |
|
So I ran a test suite on the changes and unfortunately a few of the tests failed. Not sure what the best way to share the test results are, but here are some failure excerpts: XenLivePatchTest: Networking: HAOCx2WE: Let me know how you'd like to proceed/what info you need from me. |
|
It's difficult to say whether they are related just by looking at those loglines, and I haven't seen the test runs in months to remember well how they could affect the update guidances, or hosts failing to get online. Thanks for making the builds and running the tests, it's good to know most tests passed! (I guess the ring3BVT+BST) |
The Listext module has a lot of baggage that can be replace with Stdlib, Astring. And what cannot be replaced, it can be made better, especially the escaping.
There are quite a few changes, so it's better to review commit-by-commit.
I need to do some testing to make sure all changes here are safe and undraft this