Closed
Bug 1396958
Opened 8 years ago
Closed 8 years ago
Make eTLD service cache lookup thread safe
Categories
(Core :: Networking: DNS, defect)
Core
Networking: DNS
Tracking
()
RESOLVED
FIXED
mozilla57
| Tracking | Status | |
|---|---|---|
| firefox57 | --- | fixed |
People
(Reporter: erahm, Assigned: erahm)
References
Details
(Whiteboard: [necko-active])
Attachments
(1 file, 1 obsolete file)
|
1.42 KB,
patch
|
valentin
:
review+
|
Details | Diff | Splinter Review |
Currently the eTLD service's cache is main-thread only. It would to remove this restriction so that components that want to move off main-thread can still access it.
| Assignee | ||
Comment 1•8 years ago
|
||
Adds a mutex that is used to guard lookups of and updates to the MRU cache.
This allows us to remove the main-thread only assertion in the lookup code.
Attachment #8904684 -
Flags: review?(nfroyd)
| Assignee | ||
Updated•8 years ago
|
Assignee: nobody → erahm
Status: NEW → ASSIGNED
Updated•8 years ago
|
Whiteboard: [necko-active]
Comment 2•8 years ago
|
||
Comment on attachment 8904684 [details] [diff] [review]
Make eTLD cache thread-safe
Review of attachment 8904684 [details] [diff] [review]:
-----------------------------------------------------------------
Not a huge fan of this...Would it be worth having a main-thread only cache and a everybody-else cache, and only locking for the everybody-else case? My guess is that the main thread case is overwhemingly common, but I don't really know the netwerk code all that well. Do we know what kind of performance hit this entails?
Alternatively, could we just get rid of the cache entirely?
::: netwerk/dns/nsEffectiveTLDService.cpp
@@ +313,5 @@
>
> // Update the MRU table if in use.
> if (entry) {
> + // Lock while updating the entry. We know the pointer is still valid as
> + // the table size is static and immutable.
...and do we also care that we might be overwriting a value that was now equal to the value we are now storing? I guess we don't.
Perhaps the comment should include something to the effect of "Even though we dropped the lock after the unsuccessful lookup, we know that the pointer is still valid as the table size is static and immutable, so we don't have to worry about what happened in between the dropped lock and now." So we're making it very clear that we understand what we just did, and providing context as to why this is OK.
Attachment #8904684 -
Flags: review?(nfroyd)
| Assignee | ||
Comment 3•8 years ago
|
||
(In reply to Nathan Froyd [:froydnj] from comment #2)
> Comment on attachment 8904684 [details] [diff] [review]
> Make eTLD cache thread-safe
>
> Review of attachment 8904684 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Not a huge fan of this...Would it be worth having a main-thread only cache
> and a everybody-else cache, and only locking for the everybody-else case?
> My guess is that the main thread case is overwhemingly common, but I don't
> really know the netwerk code all that well. Do we know what kind of
> performance hit this entails?
We could just make the lookup dependent on `NS_IsMainThread()` and avoid mutexes all together. I haven't measure the perf hit but we've previously gone with the assumption that uncontested locks are fast.
> Alternatively, could we just get rid of the cache entirely?
We cannot. Adding the DAFSA for eTLD lookups was a perf hit, but putting a small cache on top of it made it a perf win (bug 1380154, comment 20).
> ::: netwerk/dns/nsEffectiveTLDService.cpp
> @@ +313,5 @@
> >
> > // Update the MRU table if in use.
> > if (entry) {
> > + // Lock while updating the entry. We know the pointer is still valid as
> > + // the table size is static and immutable.
>
> ...and do we also care that we might be overwriting a value that was now
> equal to the value we are now storing? I guess we don't.
Yeah it really doesn't matter.
> Perhaps the comment should include something to the effect of "Even though
> we dropped the lock after the unsuccessful lookup, we know that the pointer
> is still valid as the table size is static and immutable, so we don't have
> to worry about what happened in between the dropped lock and now." So we're
> making it very clear that we understand what we just did, and providing
> context as to why this is OK.
Sure that makes sense, but let me know if you prefer to just not use the cache off main thread (bug 870460, comment 59 indicates it's pretty rare and being slower off main thread is maybe less of an issue).
Flags: needinfo?(nfroyd)
Comment 4•8 years ago
|
||
(In reply to Eric Rahm [:erahm] (please no mozreview requests) from comment #3)
> (In reply to Nathan Froyd [:froydnj] from comment #2)
> > Perhaps the comment should include something to the effect of "Even though
> > we dropped the lock after the unsuccessful lookup, we know that the pointer
> > is still valid as the table size is static and immutable, so we don't have
> > to worry about what happened in between the dropped lock and now." So we're
> > making it very clear that we understand what we just did, and providing
> > context as to why this is OK.
>
> Sure that makes sense, but let me know if you prefer to just not use the
> cache off main thread (bug 870460, comment 59 indicates it's pretty rare and
> being slower off main thread is maybe less of an issue).
My gut feeling is that this is what we want to do...but this is wandering into Necko territory about how often various things are used, and I have no knowledge of that.
So you should get somebody with appropriate privileges to sign off on that decision (valentin? nick hurley?); if a Necko peer thinks not caching OMT is OK, that's fine, and if they think locking all the time is appropriate, that's fine too. :)
Flags: needinfo?(nfroyd)
| Assignee | ||
Comment 5•8 years ago
|
||
(In reply to Nathan Froyd [:froydnj] from comment #4)
> My gut feeling is that this is what we want to do...but this is wandering
> into Necko territory about how often various things are used, and I have no
> knowledge of that.
>
> So you should get somebody with appropriate privileges to sign off on that
> decision (valentin? nick hurley?); if a Necko peer thinks not caching OMT
> is OK, that's fine, and if they think locking all the time is appropriate,
> that's fine too. :)
Okay, I'll update to just not cache OMT and redirect to valentin.
| Assignee | ||
Comment 6•8 years ago
|
||
Restrict the MRU cache for eTLD lookups to main thread only. This allows off
main thread lookups, but they will just take a slower path.
Attachment #8906738 -
Flags: review?(valentin.gosu)
| Assignee | ||
Updated•8 years ago
|
Attachment #8904684 -
Attachment is obsolete: true
Comment 7•8 years ago
|
||
Comment on attachment 8906738 [details] [diff] [review]
Make eTLD cache thread-safe
Review of attachment 8906738 [details] [diff] [review]:
-----------------------------------------------------------------
I guess if there is no big performance regression from this, it should all be OK.
Attachment #8906738 -
Flags: review?(valentin.gosu) → review+
| Assignee | ||
Comment 8•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/afff11392670ae77ad6da75c1df446e5a21c79b4
Bug 1396958 - Make eTLD cache thread-safe. r=valentin
Comment 9•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in
before you can comment on or make changes to this bug.
Description
•