You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Bolin Lin (Jira)" <ji...@apache.org> on 2025/09/23 02:41:00 UTC

[jira] [Commented] (HDDS-13516) Compile regex in StringToSignProducer#urlEncode once

    [ 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: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org