Closed
Bug 1376471
Opened 7 years ago
Closed 7 years ago
nsNavHistory does unnecessary hashtable lookups
Categories
(Toolkit :: Places, enhancement, P3)
Toolkit
Places
Tracking
()
RESOLVED
FIXED
mozilla56
Tracking | Status | |
---|---|---|
firefox56 | --- | fixed |
People
(Reporter: MatsPalmgren_bugz, Assigned: MatsPalmgren_bugz)
Details
(Keywords: perf)
Attachments
(1 file)
2.72 KB,
patch
|
mak
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•7 years ago
|
||
Attachment #8881419 -
Flags: review?(nfroyd)
Assignee | ||
Comment 2•7 years ago
|
||
Comment on attachment 8881419 [details] [diff] [review] Just use Put rather than Get+Remove+Put when an entry already exist This patch slightly changes the condition for when ExpireNonrecentEvents is triggered. Before: if (Count() == *_MAX_LENGTH + 1) when the method is called, Get+Remove would remove the entry if it exists and thus make the condition false if (Count() == *_MAX_LENGTH) when the method is called, the condition is always false, even if we add a new entry After: if (Count() == *_MAX_LENGTH + 1) when the method is called, the condition will be true whether or not the entry exist if (Count() == *_MAX_LENGTH) when the method is called, the condition will become true if we're adding a new entry IOW, the old behavior is that "*_MAX_LENGTH + 1" is allowed without triggering ExpireNonrecentEvents. The new behavior is that "*_MAX_LENGTH + 1" entries always triggers ExpireNonrecentEvents. I suspect the old behavior is actually a bug.
Attachment #8881419 -
Flags: feedback?(honzab.moz)
Comment 3•7 years ago
|
||
Comment on attachment 8881419 [details] [diff] [review] Just use Put rather than Get+Remove+Put when an entry already exist Review of attachment 8881419 [details] [diff] [review]: ----------------------------------------------------------------- Passing this review off because I don't have enough familiarity with the Places code to say whether this is valid or not, see below. ::: toolkit/components/places/nsNavHistory.cpp @@ -1109,5 @@ > > if (mRecentBookmark.Count() > RECENT_EVENT_QUEUE_MAX_LENGTH) > ExpireNonrecentEvents(&mRecentBookmark); > > - mRecentBookmark.Put(uriString, GetNow()); I don't know if moving this call (and the other, similar cases below) before the ExpireNonrecentEvents call is valid. Maybe ExpireNonrecentEvents relies on uriString not existing in the hashtable somehow...?
Attachment #8881419 -
Flags: review?(nfroyd) → review?(mak77)
Comment 4•7 years ago
|
||
Comment on attachment 8881419 [details] [diff] [review] Just use Put rather than Get+Remove+Put when an entry already exist Review of attachment 8881419 [details] [diff] [review]: ----------------------------------------------------------------- r=me with the question answered positively. From a quick look at http://searchfox.org/mozilla-central/source/xpcom/ds/nsBaseHashtable.h#151 it sounds like ok to me. ::: toolkit/components/places/nsNavHistory.cpp @@ +1101,5 @@ > nsAutoCString uriString; > nsresult rv = aURI->GetSpec(uriString); > NS_ENSURE_SUCCESS(rv, rv); > > + mRecentBookmark.Put(uriString, GetNow()); Does Put() actually replace the value if the key is present, or does it skip setting the value if the key exists? I'm asking exactly because of ExpireNonrecentEvents, each entry has an expiration time, and we should be sure the expiration time for this uri gets replaced, or it may be expired immediately.
Attachment #8881419 -
Flags: review?(mak77) → review+
Assignee | ||
Comment 5•7 years ago
|
||
Comment on attachment 8881419 [details] [diff] [review] Just use Put rather than Get+Remove+Put when an entry already exist Thanks for the review. Yes, if an hashtable entry already exists for the key, then Put will replace its value.
Attachment #8881419 -
Flags: feedback?(honzab.moz)
Pushed by mpalmgren@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/2c4016ee35f3 Just use Put rather than Get+Remove+Put when an entry already exist. r=froydnj
Comment 7•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2c4016ee35f3
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox56:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in
before you can comment on or make changes to this bug.
Description
•