bugGNU source-highlight - Bugs: bug #64747, Slow processing of file with long...

 
 

bug #64747: Slow processing of file with long lines

Submitter:  None
Submitted:  Thu 05 Oct 2023 06:34:51 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 11 Oct 2023 07:25:22 AM UTC, comment #3: 
Tom de Vries <vries>
Tue 10 Oct 2023 11:06:08 AM UTC, comment #2: 

Attaching tentative patch:
- passes make check,
- for test.cpp, generates identical output and takes execution
  time down from 2m13s to 3s.

(file #55226)

Anonymous
Mon 09 Oct 2023 12:16:19 PM UTC, comment #1: 

Using this patch, I'm capping the search window to 1024 bytes:
...
diff --git a/lib/srchilite/regexhighlightrule.cpp b/lib/srchilite/regexhighlightrule.cpp
index 458e63f..5ffa458 100644
--- a/lib/srchilite/regexhighlightrule.cpp
+++ b/lib/srchilite/regexhighlightrule.cpp
@@ -46,7 +46,13 @@ bool RegexHighlightRule::tryToMatch(std::string::const_iterator start,
         flags |= boost::match_not_bol;
     }
 
-    if (boost::regex_search(start, end, match, regExp, flags)) {
+    size_t n = 1024;
+    std::string::const_iterator search_end;
+    if (end - start > n)
+      search_end = start + n;
+    else
+      search_end = end;
+    if (boost::regex_search(start, search_end, match, regExp, flags)) {
         token.prefix = match.prefix();
         token.suffix = match.suffix();
 
...
and that takes overall execution down to 1.5 seconds.

Anonymous
Thu 05 Oct 2023 06:34:51 AM UTC, original submission:  

[ Reported first as gdb PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=30934 ). ]

When using an example with longer lines:
...
$ wc test.cpp
    80    229 293884 test.cpp
...
we have:
...
$ time source-highlight test.cpp > /dev/null
Processing test.cpp ... created test.cpp.html

real 2m13.220s
user 2m10.213s
sys 0m3.004s
...
and when using pygments:
...
$ time pygmentize test.cpp > /dev/null

real 0m2.017s
user 0m2.005s
sys 0m0.012s
...

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55226:  0001-fix.patch added by None (8KiB - text/x-patch - tentative patch)
file #55203:  test.cpp.gz added by None (105KiB - application/gzip - test.cpp.gz)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by vries (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-10 None Attached File- Added 0001-fix.patch, #55226
    2023-10-05 None Attached File- Added test.cpp.gz, #55203

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code