[ 
https://issues.apache.org/jira/browse/HDDS-13516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022007#comment-18022007
 ] 

Bolin Lin commented on HDDS-13516:
----------------------------------

Hi [~ivanandika], 
Which way do you like? pre-compile or using *replace* instead.  From the medium 
you shared, looks like *replace* actually gives better performance than 
pre-compile.

> Compile regex in StringToSignProducer#urlEncode once
> ----------------------------------------------------
>
>                 Key: HDDS-13516
>                 URL: https://issues.apache.org/jira/browse/HDDS-13516
>             Project: Apache Ozone
>          Issue Type: Improvement
>            Reporter: Ivan Andika
>            Assignee: Bolin Lin
>            Priority: Minor
>         Attachments: image-2025-07-28-22-19-44-883.png
>
>
> StringToSignProducer#urlEncode uses Strings#replaceAll that will call 
> Pattern#compile for every invocation. This adds some memory overhead.
> !image-2025-07-28-22-19-44-883.png|width=1109,height=169!
> This can be improved by compiling the regex once. Please also add a simple 
> microbenchmark (before and after the optimization) to prove that performance 
> is indeed improved.
> See: 
> https://medium.com/javarevisited/micro-optimizations-in-java-string-replaceall-c6d0edf2ef6



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to