Author Topic: Nasty performance problem with bookmarks  (Read 4042 times)

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Nasty performance problem with bookmarks
« on: August 28, 2007, 10:41:51 pm »
For a while now, I have had significant delays whenever I start SlickEdit or change workspaces.  I had put it down to having my workspace and project files on a network share on my OS/2 Virtual PC.  But today, I had closed the current workspace before I shut SlickEdit down, and then reopened it, and it still had the delay.  By chance, I was also running a network monitoring tool, and it showed that my gigabit Ethernet card was maxing out (400 Kibytes/s of incoming traffic).  So I shut down SlickEdit again and ran Wireshark (was: Ethereal) to capture the traffic as I reopened SlickEdit.  It showed that SlickEdit was opening and reading a 19 Mibyte log file in one of my projects on the OS/2 Virtual PC.  As you can imagine, it takes a while to read a 19 Mibyte file, even over gigabit ethernet.  So I shut down SlickEdit again, went to my 12.0.3 configuration directory, and grepped all the files for the name of the log file it was loading.  It turned up in the BOOKMARK2 section at the end of vrestore.slk.  So I reopened SlickEdit again, and did Alt-J (goto-bookmark) and sure enough, there was a bookmark in that huge log file.  I deleted all the bookmarks I had there (they were all out of date anyway) and shut down and reopened SlickEdit again, and the delay was gone.

So, it seems that for any bookmark, when you open SlickEdit, it will open the bookmarked file and read through it, at least as far as the bookmark and maybe even the entire file.  If the files are small, as they typically are, then there is no problem.  If the files are big but on a local hard disk, there will be a small problem.  But if they are big and on a network share or other slow device, big problem.

I wonder how many other people out there use bookmarks in huge files and have been suffering from this?

Is there really a need to load all bookmarked files at startup?  Would it not be better to only load them on demand, when the bookmark is actually used?

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: Nasty performance problem with bookmarks
« Reply #1 on: August 28, 2007, 10:57:23 pm »
... and when I opened one of my workspaces, the startup delay was back again.  It turns out that the bookmarks are stored in the workspace file as well as vrestore.slk, so I will have to delete the problem bookmarks from all affected workspaces.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5010
  • Hero Points: 417
Re: Nasty performance problem with bookmarks
« Reply #2 on: August 30, 2007, 03:09:13 pm »
Backup your bookmark.e and replace the function below with this code for V12.03.  The load the new bookmark.e (Macro, Load Module).  It is much more optimized that the current bookmark auto-restore code. 

_str _sr_bookmark2(_str option='',_str info='')
{
   typeless vsbmflags=0;
   typeless Nofbookmarks=0;
   int i=0;
   _str line='';

   typeless BookmarkName='';
   typeless markid='';
   typeless bufid=0;
   typeless RealLineNumber=0;
   typeless col=0;
   typeless BeginLineROffset=0;
   typeless LineData='';
   typeless Filename='';
   typeless DocumentName='';

   if ((!def_use_workspace_bm) && //If we're using global bookmarks ...
       (p_buf_name :== "")) { //if p_buf_name is not set, it's not vrestore.slk
      return (0);
   }

   if ( option=='R' || option=='N' ) {
      clear_bookmarks("quiet");
      parse info with Nofbookmarks .;
      for (i=1; i<=Nofbookmarks ; ++i) {
         down();
         get_line(line);
         parse line with BookmarkName \1 vsbmflags \1 RealLineNumber \1 col \1 BeginLineROffset \1 LineData \1 Filename \1 DocumentName;
         if (def_bm_show_picture) {
            vsbmflags |= (VSBMFLAG_SHOWNAME|VSBMFLAG_SHOWPIC);
         } else {
            vsbmflags &= ~(VSBMFLAG_SHOWNAME|VSBMFLAG_SHOWPIC);
         }

         markid=_alloc_selection('B');
         int temp_view_id;
         int orig_view_id;
         int status = _open_temp_view(Filename,temp_view_id,orig_view_id,'+b');
         if (status) {
            _BookmarkAdd(BookmarkName,markid,vsbmflags,RealLineNumber,col,
                         BeginLineROffset,LineData,Filename,DocumentName);
         } else {
            _str on,value;
            parse def_max_loadall with on value;
            if (RealLineNumber>=0 && !(on && isinteger(value) && BeginLineROffset>value)) {
               p_RLine=RealLineNumber;
            } else {
               _GoToROffset(BeginLineROffset);
            }
            p_col=col;
            _select_char(markid);
            _BookmarkAdd(BookmarkName,markid,vsbmflags);
            _delete_temp_view(temp_view_id);
            activate_window(orig_view_id);
         }
      }
      updateBookmarksToolWindow(0);
   } else {
      insert_line("");
      int orig_line=p_line;
      Nofbookmarks=0;
      for (i=0;i<_BookmarkQCount();++i) {
         _BookmarkGetInfo(i,BookmarkName,markid,vsbmflags,
                          bufid,
                          0,RealLineNumber,col,BeginLineROffset,LineData,
                          Filename,DocumentName);
         if (!(vsbmflags & VSBMFLAG_STANDARD)) {
            continue;
         }
         ++Nofbookmarks;
         LineData=stranslate(LineData,"",\1);
         LineData=stranslate(LineData,"","\n");
         insert_line(BookmarkName \1 vsbmflags \1 RealLineNumber \1 col \1 BeginLineROffset \1 LineData \1 Filename \1 DocumentName);
      }
      int orig_line2=p_line;
      p_line=orig_line;
      replace_line("BOOKMARK2: "Nofbookmarks);
      p_line=orig_line2;

      //get_line(line);
      //_message_box(line);
   }
   return (0);

}

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: Nasty performance problem with bookmarks
« Reply #3 on: August 30, 2007, 10:46:05 pm »
That is so much better!  Now SlickEdit loads at the usual speed, no matter what is bookmarked.  Only if you actually use the bookmark does it go and read through the file.  Thank you!