You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sean Patrick Floyd (JIRA)" <ji...@apache.org> on 2009/02/25 12:22:02 UTC
[jira] Created: (WICKET-2127) Javascript function Wicket.replaceAll
is unbearably slow
Javascript function Wicket.replaceAll is unbearably slow
--------------------------------------------------------
Key: WICKET-2127
URL: https://issues.apache.org/jira/browse/WICKET-2127
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.4-RC2
Environment: Firefox 3.0.5, Opera 9.2 (windows)
Reporter: Sean Patrick Floyd
Fix For: 1.4-RC3
I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
After a while, the browser occupies 50% or more of the system resources.
I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679120#action_12679120 ]
Matej Knopp commented on WICKET-2127:
-------------------------------------
This one
var replaceAll = function(str, from, to) {
eval(
'var regex = /' + from.replace( /\W/g ,'\\$&' ) + '/g ;'
);
return str.replace(regex,to);
}
looks good to me. I will apply it to 1.4 and if no one complains after same time I will probably also add it to 1.3.
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676725#action_12676725 ]
knopp edited comment on WICKET-2127 at 2/25/09 10:15 AM:
---------------------------------------------------------------
You replacement function is broken. It needs to escape more characters. I added some.
var replaceAll = function(str, from, to) {
eval(
'var regex = /'
+ from.replace( /[\(\)\[\]\{\}\$\^\.\?\*\+\\\/\|]/g ,'\\$&' )
+ '/g ;'
);
return str.replace(regex,to);
}
I don't mind replacing the current function with this but at this point I'm not sure it escapes all necessary characters.
was (Author: knopp):
You replacement function is broken. It needs to escape more characters. I added some.
var replaceAll = function(str, from, to) {
eval(
'var regex = /'
+ from.replace( /[\(\)\[\]\{\}\$\^\.\?\*\+\\\/]/g ,'\\$&' )
+ '/g ;'
);
return str.replace(regex,to);
}
I don't mind replacing the current function with this but at this point I'm not sure it escapes all necessary characters.
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Sean Patrick Floyd (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679139#action_12679139 ]
Sean Patrick Floyd commented on WICKET-2127:
--------------------------------------------
Thanks.
Sean
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678927#action_12678927 ]
kan.izh edited comment on WICKET-2127 at 3/4/09 1:25 PM:
--------------------------------------------------------------------
Also
function removeIframeMark(text) {
var markerRe = new RegExp(marker, "g") //this variable could be cached somewhere globally, so we could avoid regex compilation every time if it affects performance
return text.replace(markerRe, "")
}
Wicket.decode1 = function(text) {
return text.replace(/\]\^/g, "]")
}
was (Author: kan.izh):
Also
function removeIframeMark(text) {
var markerRe = new RegExp(marker, "g") //this variable could be cached somewhere globally, so we could avoid regex compilation if it affects performance
return text.replace(markerRe, "");
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Sean Patrick Floyd (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676615#action_12676615 ]
Sean Patrick Floyd commented on WICKET-2127:
--------------------------------------------
Forgot to mention: The Source file in question is wicket-ajax.js in package org.apache.wicket.ajax
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676725#action_12676725 ]
Matej Knopp commented on WICKET-2127:
-------------------------------------
You replacement function is broken. It needs to escape more characters. I added some.
var replaceAll = function(str, from, to) {
eval(
'var regex = /'
+ from.replace( /[\(\)\[\]\{\}\$\^\.\?\*\+\\\/]/g ,'\\$&' )
+ '/g ;'
);
return str.replace(regex,to);
}
I don't mind replacing the current function with this but at this point I'm not sure it escapes all necessary characters.
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-2127) Javascript function Wicket.replaceAll
is unbearably slow
Posted by "Sean Patrick Floyd (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Patrick Floyd updated WICKET-2127:
---------------------------------------
Attachment: wicketReplaceAll.js
Using this version of Wicket.replaceAll changed the performance dramatically.
Now the FireBugs Profiler says the script takes up 1.98% of the processing time as opposed to ~60%
Sean
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-2127) Javascript function Wicket.replaceAll
is unbearably slow
Posted by "Jeremy Thomerson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jeremy Thomerson updated WICKET-2127:
-------------------------------------
Fix Version/s: (was: 1.4-RC3)
1.4-RC4
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC4
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678925#action_12678925 ]
Anatoly Kupriyanov commented on WICKET-2127:
--------------------------------------------
I am not sure what do you want to do, but you can use RegExp object, so this:
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-2127) Javascript function Wicket.replaceAll
is unbearably slow
Posted by "Jeremy Thomerson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jeremy Thomerson updated WICKET-2127:
-------------------------------------
Fix Version/s: (was: 1.4-RC5)
1.4-RC6
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC6
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678925#action_12678925 ]
kan.izh edited comment on WICKET-2127 at 3/4/09 1:16 PM:
--------------------------------------------------------------------
I am not sure what do you want to do, but you can use RegExp object, so this:
[code]
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
[/code]
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
was (Author: kan.izh):
I am not sure what do you want to do, but you can use RegExp object, so this:
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679120#action_12679120 ]
knopp edited comment on WICKET-2127 at 3/5/09 2:34 AM:
-------------------------------------------------------------
This one
var replaceAll = function(str, from, to) {
eval(
'var regex = /' + from.replace( /\W/g ,'\\$&' ) + '/g ;'
);
return str.replace(regex,to);
}
looks good to me. I will apply it to 1.4 and if no one complains after some time I will probably also add it to 1.3.
was (Author: knopp):
This one
var replaceAll = function(str, from, to) {
eval(
'var regex = /' + from.replace( /\W/g ,'\\$&' ) + '/g ;'
);
return str.replace(regex,to);
}
looks good to me. I will apply it to 1.4 and if no one complains after same time I will probably also add it to 1.3.
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matej Knopp resolved WICKET-2127.
---------------------------------
Resolution: Fixed
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC6
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678925#action_12678925 ]
kan.izh edited comment on WICKET-2127 at 3/4/09 1:16 PM:
--------------------------------------------------------------------
I am not sure what do you want to do, but you can use RegExp object, so this:
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
was (Author: kan.izh):
I am not sure what do you want to do, but you can use RegExp object, so this:
[code]
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
[/code]
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-2127) Javascript function Wicket.replaceAll
is unbearably slow
Posted by "Jeremy Thomerson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jeremy Thomerson updated WICKET-2127:
-------------------------------------
Fix Version/s: (was: 1.4-RC4)
1.4-RC5
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC5
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678925#action_12678925 ]
kan.izh edited comment on WICKET-2127 at 3/4/09 1:19 PM:
--------------------------------------------------------------------
I am not sure what do you want to do, but you can use RegExp object, so this:
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker + "iframe");
}
was (Author: kan.izh):
I am not sure what do you want to do, but you can use RegExp object, so this:
function(str, from, to) {
var re = from.replace(/(\W)/g, "\\$1");
return str.replace(new RegExp(re, "g"), to);
}
But my advice, don't do generic method replaceAll, but use replace with g modifier. Say in method
function markIframe(text) {
var t = text;
var r = /<\s*iframe/i;
while ((m = t.match(r)) != null) {
t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1));
}
return t;
}
it's enough just do
function markIframe(text) {
return text.replace(/<\s*iframe/ig, "<"+marker);
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Sean Patrick Floyd (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12677255#action_12677255 ]
Sean Patrick Floyd commented on WICKET-2127:
--------------------------------------------
Actually, it should work to just escape all non-word characters in the search String.
Here is another version that does just this:
var replaceAll = function(str, from, to) {
eval(
'var regex = /' + from.replace( /\W/g ,'\\$&' ) + '/g ;'
);
return str.replace(regex,to);
}
Sean
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (WICKET-2127) Javascript function Wicket.replaceAll
is unbearably slow
Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matej Knopp closed WICKET-2127.
-------------------------------
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC6
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679169#action_12679169 ]
Anatoly Kupriyanov commented on WICKET-2127:
--------------------------------------------
I understand, I mean somebody should just fix the code in wicket source itself.
The code "while ... Wicket.replaceAll" is very inefficient - it creates a lot of string objects and has bad algorithmic complexity (quadratic instead of linear). It could be done by single replace(/.../g) which should work much more faster.
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Sean Patrick Floyd (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676894#action_12676894 ]
Sean Patrick Floyd commented on WICKET-2127:
--------------------------------------------
I know. Unfortunately there is neither a Pattern.quote() nor an inline quote like \Q in JavaScript. It's not really readable either. But the performance is catastrophic without it.
Sean
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg reassigned WICKET-2127:
-------------------------------------
Assignee: Matej Knopp
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Sean Patrick Floyd (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679087#action_12679087 ]
Sean Patrick Floyd commented on WICKET-2127:
--------------------------------------------
Anatoly,
I never call this function myself. The wicket AJAX behaviors call it when updating the page.
So just having a timed auto update behavior that updates parts of my page every 5 seconds or so brought my system to a freeze.
Sean
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2127) Javascript function
Wicket.replaceAll is unbearably slow
Posted by "Anatoly Kupriyanov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678927#action_12678927 ]
Anatoly Kupriyanov commented on WICKET-2127:
--------------------------------------------
Also
function removeIframeMark(text) {
var markerRe = new RegExp(marker, "g") //this variable could be cached somewhere globally, so we could avoid regex compilation if it affects performance
return text.replace(markerRe, "");
}
> Javascript function Wicket.replaceAll is unbearably slow
> --------------------------------------------------------
>
> Key: WICKET-2127
> URL: https://issues.apache.org/jira/browse/WICKET-2127
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC2
> Environment: Firefox 3.0.5, Opera 9.2 (windows)
> Reporter: Sean Patrick Floyd
> Assignee: Matej Knopp
> Fix For: 1.4-RC3
>
> Attachments: wicketReplaceAll.js
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> I use AbstractAjaxTimerBehavior to update many different components on my pages periodically.
> After a while, the browser occupies 50% or more of the system resources.
> I used the javascript profiler in firebug and found that Wicket.replaceAll is responsible for 60+ percent of javascript processing time.
> The problem is that sequential string processing is used instead of much faster regular expressions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.