Skip to content

Conversation

@taylor-steve
Copy link
Contributor

@taylor-steve taylor-steve commented Nov 5, 2025

With the same test setup as #103 I'm seeing we could make some performance savings by not recompiling the regex in each call of validate_uri.

"allocated memory by class" for Regex goes from 9268983 to 31073

Copy link
Collaborator

@jcoyne jcoyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing that URI::regexp is obsolete. https://github.com/ruby/uri/blob/f1b05c89ab38667e7564896f994d4d6cfbc67149/lib/uri/common.rb#L339 I wonder if we can replace this with URI(val) and trap exceptions instead?

@taylor-steve taylor-steve changed the title Precompile abstract resource valid URI regex Stop using obsolete URI.regexp for validation Nov 6, 2025
@taylor-steve
Copy link
Contributor Author

Good catch. This saves 3x on memory for the test case compared to my original.

@jcoyne jcoyne merged commit 965c1ff into iiif-prezi:main Nov 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants