Closed Bug 395066 Opened 17 years ago Closed 17 years ago

Hang when trying to clear browsing history

Categories

(Firefox :: Bookmarks & History, defect, P1)

defect

Tracking

()

VERIFIED FIXED
Firefox 3 beta1

People

(Reporter: martijn.martijn, Assigned: dietrich)

Details

Attachments

(2 files, 2 obsolete files)

When trying to clear my private data, current trunk Firefox hung.
It took long enough to be annoyed by it (>10s), so I killed the Firefox process.

It happened even when I only had the "Browsing History" option checked.

I had a lot of history items in there.
With the SQLite data browser I got40300 for the amount of moz_historyvisits.

And my places.sqlite file had 14MB as size, in case that matters.
The trunk is currently very slow when clearing history, just wait until it's finished. Since we're now storing history for 180 days by default, this has become much annoying. It will takes minutes ! And because there's no progress dialogbox, people will assume that Firefox is hanging.

Too bad that Sqlite doesn't offer a "truncate table" command :-(

Maybe as a workaround (if we don't find ther cause), we can drop the tablr and recreate it ?
That sounds bad, and I think this will be something that people will encounter.
Flags: blocking-firefox3?
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a8pre) Gecko/2007090614 Minefield/3.0a8pre ID:2007090614

I have a 45.1MB places.sqlite file and a 45 day browsing history. I made a new profile, copied my usual places.sqlite to it, started firefox up with the new profile, Tools > Clear Private Data, and chose to just clear my browsing history. It took my AlthonXP2400 on win2k _1hr32min_ of 99% CPU usage to clear the browser history.
thanks (as always) to martjin, jo and steve.  I'll take a look into this ASAP.
Assignee: nobody → sspitzer
Here's the breakdown of time in ExpireItems() in seconds, when clearing history in my places.sqlite of 25mb:

FindVisits: 0
EraseVisits: 1
EraseHistory: 12
EraseFavicons: 0
EraseAnnos: 36
For EraseAnnotations, can't we use the same optimization as in bug 386711, issuing a single sql-statement with an in-expression (see EraseVisits) ?

(In reply to comment #6)
> For EraseAnnotations, can't we use the same optimization as in bug 386711,
> issuing a single sql-statement with an in-expression (see EraseVisits) ?
> 

Yes, that's what I'm currently writing :)
Attached patch fix 1 - fixes EraseAnnotations (obsolete) — Splinter Review
Assignee: sspitzer → dietrich
Status: NEW → ASSIGNED
Attachment #280125 - Flags: review?(sspitzer)
(In reply to comment #8)
> Created an attachment (id=280125) [details]
> fix 1 - fixes EraseAnnotations
> 

this brought EraseAnnotations from 36 secs to <0 secs w/ my profile.
removes unnecessary anno svc.
Attachment #280125 - Attachment is obsolete: true
Attachment #280127 - Flags: review?(sspitzer)
Attachment #280125 - Flags: review?(sspitzer)
Comment on attachment 280127 [details] [diff] [review]
fix 1 - fixes EraseAnnotations (v2)

r=sspitzer, but 

1) don't check in your timing / printf code.

2) use nsCString instead of nsCAutoString, as mentioned over irc, because, for lots of ids

nsAutoString / nsCAutoString- derived from nsString, a string which owns a 64 code unit buffer in the same storage space as the string itself. If a string less than 64 code units is assigned to an nsAutoString, then no extra storage will be allocated. For larger strings, a new buffer is allocated on the heap.
Attachment #280127 - Flags: review?(sspitzer) → review+
Flags: in-litmus?
I think dietrich also has a fix for EraseHistory().

dietrich, do you think this will make m8?
OS: Windows XP → All
Hardware: PC → All
cleaned up patch, carrying over r=sspitzer.

requestion 1.9 approval: this fixes the bug to a large extent. i'm still working on fixing EraseHistory(), but as that's the lesser problem, we shouldn't block on getting this in for M8.
Attachment #280127 - Attachment is obsolete: true
Attachment #280178 - Flags: approval1.9?
Attachment #280178 - Flags: approval1.9? → approval1.9+
checked in the fix to annotations. i'm still working on a fix for deleting moz_places records, so leaving this bug open. reporter(s), please comment with how long it takes after this fix.

Checking in toolkit/components/places/src/nsNavHistoryExpire.cpp;
/cvsroot/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp,v  <--  nsNavHistoryExpire.cpp
new revision: 1.16; previous revision: 1.15
done
Checking in toolkit/components/places/tests/unit/test_expiration.js;
/cvsroot/mozilla/toolkit/components/places/tests/unit/test_expiration.js,v  <--  test_expiration.js
new revision: 1.7; previous revision: 1.6
done
Priority: -- → P1
Target Milestone: --- → Firefox 3 M9
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a8pre) Gecko/2007091002 Minefield/3.0a8pre

With a new profile and my existing places.sqlite (45.1MB, 45 day history), Clear Private Data took 4m12s to clear my history - a vast improvement from over an hour and a half!
Litmus Triage Team: further discussion is needed about the best way to create a Litmus case around this. Perhaps if we have a dirty profile from my profile project that can be accessed, it could be worked.
as done in the other functions, you could add also into eraseAnnotation an early return to avoid the query if there are no ids to delete

if (placeIds.IsEmpty())
  return NS_OK;

and probably nsCAutoString in other erase functions could be converted to nsCString per comment #11

On my 28MB places.sqlite clear history (only browsing history) took about 1,55 minutes
i've tried with different queries on erasehistory, the only one i got an advantage is this, i moved from 1,55 minutes to 1,35 minutes, so if someone wants to give it a try... other queries did not move the timing, even if they were more compact

this does also the cleanup on autostring and early return
Flags: blocking-firefox3? → blocking-firefox3+
Comment on attachment 280878 [details] [diff] [review]
attempted patch to erasehistory (and cleanup)

this looks good, and passes the unit tests. thanks Marco!
Attachment #280878 - Flags: review+
does this need other reviews? 
if not this should be checkin-needed
Keywords: checkin-needed
Checking in toolkit/components/places/src/nsNavHistoryExpire.cpp;
/cvsroot/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp,v  <--  nsNavHistoryExpire.cpp
new revision: 1.17; previous revision: 1.16
done
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Things such as hangs, crashes and other general nastiness are implicit failures for any test case.  

The test case for clearing browser history is already in Litmus: https://litmus.mozilla.org/show_test.cgi?id=4141

also marking verified per comments stating vast clear history improvement.
Status: RESOLVED → VERIFIED
Flags: in-litmus? → in-litmus+
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".

In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body   contains   places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.

Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.

Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: