After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 325853 - search and replace hangs (or runs much to long)
search and replace hangs (or runs much to long)
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: general
2.30.x
Other other
: Normal normal
: ---
Assigned To: Gedit maintainers
gedit QA volunteers
: 369442 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-01-05 12:41 UTC by j.lolling
Modified: 2013-07-13 10:30 UTC
See Also:
GNOME target: ---
GNOME version: 2.29/2.30


Attachments
XML-File to reproduce this bug (361.06 KB, application/octet-stream)
2006-01-05 15:02 UTC, j.lolling
  Details
patch to disable bracket-matching during replace-all (1.24 KB, patch)
2006-02-04 09:26 UTC, James "Doc" Livingston
committed Details | Review
disable search-highlight during replace-all (1.04 KB, patch)
2006-02-08 11:56 UTC, James "Doc" Livingston
committed Details | Review

Description j.lolling 2006-01-05 12:41:41 UTC
Distribution: Unknown
Package: gedit
Severity: Normal
Version: GNOME2.12.0 2.12.x
Gnome-Distributor: SUSE
Synopsis: search and replace hangs (or runs much to long)
Bugzilla-Product: gedit
Bugzilla-Component: general
Bugzilla-Version: 2.12.x
Description:
Description of Problem:
replace text in a large XML-file (6.1 MByte) hangs (run more than 20
minutes)

Steps to reproduce the problem:
1. open replace dialog
2. enter text to replacing
3. the cpu load raise to 100% and nothing happens

Actual Results:
nothing will replaced, editor must killed with kill command

Expected Results:
text will be replaced

How often does this happen?


Additional Information:




------- Bug created by bug-buddy at 2006-01-05 12:41 -------

Comment 1 Baptiste Mille-Mathias 2006-01-05 12:47:19 UTC
Hello,

I've been said this issue was known on the 2.12 version, and was resolved in the development version.
Could you provide your XML file gunzipped? and so I will test it with the version 2.13. I need to know also what pattern did you replace.

Thanks you
Comment 2 j.lolling 2006-01-05 15:02:45 UTC
Created attachment 56815 [details]
XML-File to reproduce this bug

The search pattern is not important. I could reproduce this bug with various patterns.
Comment 3 Baptiste Mille-Mathias 2006-01-05 18:33:08 UTC
I wanted to know how many item the function ahd to replace (like ten, or a thousand).

thanks
Comment 4 Baptiste Mille-Mathias 2006-01-05 18:56:52 UTC
I tried to replace "Track Number" by "track number" and I had the same behaviour so confirming.
I don't know if it useful but I have a stacktrace

Thread 1 (Thread -1225701152 (LWP 7336))

  • #0 IA__gtk_text_layout_draw
    at gtktextdisplay.c line 770
  • #1 IA__gtk_text_layout_draw
    at gtktextdisplay.c line 774
  • #2 IA__gtk_text_iter_forward_line
    at gtktextiter.c line 2545
  • #3 _gtk_text_btree_char_is_invisible
    at gtktextbtree.c line 2487
  • #4 _gtk_text_btree_char_is_invisible
    at gtktextbtree.c line 2550
  • #5 IA__gtk_text_iter_get_toggled_tags
    at gtktextiter.c line 1126
  • #6 gtk_source_buffer_set_escape_char
    from /usr/lib/libgtksourceview-1.0.so.0
  • #7 gtk_source_buffer_delete_marker
  • #8 _gtk_marshal_VOID__STRING_INT_POINTER
    at gtkmarshalers.c line 1024
  • #9 g_type_class_meta_marshal
    at gclosure.c line 567
  • #10 IA__g_closure_invoke
    at gclosure.c line 490
  • #11 signal_emit_unlocked_R
    at gsignal.c line 2487
  • #12 IA__g_signal_emit_valist
    at gsignal.c line 2208
  • #13 IA__g_signal_emit
    at gsignal.c line 2252
  • #14 IA__gtk_text_buffer_begin_user_action
    at gtktextbuffer.c line 3610
  • #15 gedit_document_replace_all
  • #16 gedit_cmd_help_about
  • #17 IA__g_cclosure_marshal_VOID__INT
    at gmarshal.c line 216
  • #18 IA__g_closure_invoke
    at gclosure.c line 490
  • #19 signal_emit_unlocked_R
    at gsignal.c line 2449
  • #20 IA__g_signal_emit_valist
    at gsignal.c line 2208
  • #21 IA__g_signal_emit
    at gsignal.c line 2252
  • #22 IA__gtk_dialog_response
    at gtkdialog.c line 858
  • #23 action_widget_activated
    at gtkdialog.c line 557
  • #24 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #25 IA__g_closure_invoke
    at gclosure.c line 490
  • #26 signal_emit_unlocked_R
    at gsignal.c line 2449
  • #27 IA__g_signal_emit_valist
    at gsignal.c line 2208
  • #28 IA__g_signal_emit
    at gsignal.c line 2252
  • #29 IA__gtk_button_clicked
    at gtkbutton.c line 834
  • #30 gtk_real_button_released
    at gtkbutton.c line 1369
  • #31 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #32 g_type_class_meta_marshal
    at gclosure.c line 567
  • #33 IA__g_closure_invoke
    at gclosure.c line 490
  • #34 signal_emit_unlocked_R
    at gsignal.c line 2379
  • #35 IA__g_signal_emit_valist
    at gsignal.c line 2208
  • #36 IA__g_signal_emit
    at gsignal.c line 2252
  • #37 IA__gtk_button_released
    at gtkbutton.c line 826
  • #38 gtk_button_button_release
    at gtkbutton.c line 1262
  • #39 gtk_marshal_VOID__UINT_POINTER_UINT_ENUM_ENUM_POINTER
    at gtkmarshal.c line 1025
  • #40 g_type_class_meta_marshal
    at gclosure.c line 567
  • #41 IA__g_closure_invoke
    at gclosure.c line 490
  • #42 signal_emit_unlocked_R
    at gsignal.c line 2487
  • #43 IA__g_signal_emit_valist
    at gsignal.c line 2218
  • #44 IA__g_signal_emit
    at gsignal.c line 2252
  • #45 _gtk_widget_get_accel_path
    at gtkwidget.c line 3430
  • #46 gtk_invoke_idle_timeout
    at gtkmain.c line 1960
  • #47 IA__gtk_main_do_event
    at gtkmain.c line 1308
  • #48 gdk_event_dispatch
    at gdkevents-x11.c line 2299
  • #49 IA__g_main_context_dispatch
    at gmain.c line 1913
  • #50 g_main_context_iterate
    at gmain.c line 2544
  • #51 IA__g_main_loop_run
    at gmain.c line 2748
  • #52 IA__gtk_key_snooper_remove
    at gtkmain.c line 1652
  • #53 main

Comment 5 Paolo Maggi 2006-01-05 19:20:48 UTC
Baptiste: Stack traces are not useful in this cases.
Could you please try to gather some profiling information using sysprof (http://live.gnome.org/Sysprof)?
Thanks for you help.
Comment 6 j.lolling 2006-01-06 00:56:45 UTC
I tried to replace more than thousand items to replace.

(In reply to comment #3)
> I wanted to know how many item the function ahd to replace (like ten, or a
> thousand).
> 
> thanks
> 

Comment 7 Paolo Borelli 2006-01-06 11:57:23 UTC
The problem is that gtksourceview spends a shitload of time rehighlighting the text because it does it for every delete and insert (that is twice for every match!)

If you turn off highlighting (for instance choosing Edit->Highlight Mode->Normal) the replace all is fairly fast (at least on 2.13... on 2.12 it will be not really fast but way shorter than 20 mins!)
Comment 8 James "Doc" Livingston 2006-02-04 09:26:18 UTC
Created attachment 58694 [details] [review]
patch to disable bracket-matching during replace-all

I've been seeing this too, so I did a bit of profiling.

With cvs HEAD, I'm seeing ~70% of the time being spent in gtk_source_buffer_delete_range, most of which is because gtk_source_buffer_move_cursor is doing bracket-matching to highlight matching brackets. Doing this during the middle of the replace operation seems a bit silly.


This patch disables the bracket-matching during replace-all operations. For the file I tested, this reduced the time from about 10 minutes to 3, a significant part of which was redoing the layout (which takes a fair while on startup for this file).

Whether there are any negative side-effects that need to be worked around, such as having to do the bracket-matching a single time once it's finished, I'm not sure.
Comment 9 Paolo Borelli 2006-02-04 10:28:29 UTC
For the testcase provided above, this doesn't seem to make much difference. As noted above all the time seems to be spent redong the highlighting and the replace becomes pretty fast when the highlighting is turned off.

On the other hand the patch makes perfect sense and you say that there are cases where it matters. 

With regard to side effects: the bracket matching should be reevaluated when the feature is turned back on... this doesn't happen at the moment, but it's a gtksourceview bug.

Patch applied.
Comment 10 James "Doc" Livingston 2006-02-08 11:56:04 UTC
Created attachment 58923 [details] [review]
disable search-highlight during replace-all

This turns off search-highliting during the operation, which provide another speed boost.

For the file I have been testing against, the remaining profile is 45% pango and 50% utf8 stuff (match case was off).
Comment 11 James "Doc" Livingston 2006-02-08 12:34:35 UTC
Patch committed to cvs.
Comment 12 Paolo Maggi 2006-02-09 13:36:58 UTC
You said 45% of time is spent in Pango. Is this true also when syntax highlighting  is disabled? Does the undo manager play some role too?
May be we should try to "freeze" syntax highlighting when running replace all.

Do you see some way for optiming the UTF-8 stuff too?
Comment 13 Paolo Borelli 2006-02-09 13:50:34 UTC
As discussed with James on irc, I don't like the idea of freezing the highlighting very much. At least until we are positive that it's a real bottleneck and not just a bug.

In particular see http://bugzilla.gnome.org/show_bug.cgi?id=330406 which was filed in realation to some further investigations.

If (and only if) we really need a way to explicitely freeze the HL from the caller, it should only freeze the 'batch processing', that is the exposed part of the buffer should still be highlighted so that the user scrolls the view he stills sees the highlighting.
Comment 14 Paolo Maggi 2006-11-04 10:31:16 UTC
*** Bug 369442 has been marked as a duplicate of this bug. ***
Comment 15 Robert Roth 2010-11-15 18:23:07 UTC
Search and replace is still slow in 2.30.3. Tried the steps described here https://bugs.launchpad.net/ubuntu/+source/gedit/+bug/45174 and gEdit stopped responding for a few seconds, without any progress indication.
Comment 16 Sébastien Wilmet 2013-07-13 10:30:56 UTC
Fixed with the async search API in GtkSourceView.