Closed Bug 1456888 Opened 5 years ago Closed 5 years ago

Use Linux filesystem type to decide about NSS SQL DB caching and speed measuring

Categories

(NSS :: Libraries, enhancement)

3.35
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: KaiE, Assigned: KaiE)

References

Details

Attachments

(2 files, 1 obsolete file)

As described in bug 1432484 users may experience slow NSS performance when storing the NSS SQL DB on a slow network filesystem.

The workaround is to manually define environment variable NSS_SDB_USE_CACHE, which may be used to explicitly to automatically enable caching.

Firefox has implemented bug 1444943 which enables caching automatically if the NSS DB is stored on an NFS filesystem.

I like the approach that has been discovered in that Firefox bug, but I think the detection should be extended to cover a wider set of filesystems (not just NFS), and in addition I think the filesystem type check should be done at the NSS code level, to help as many applications as possible,
Attached patch 1456888-v1.patch (obsolete) — Splinter Review
Initial patch for discussion. Only Linux so far.
Assignee: nobody → kaie
Summary: Enable NSS SQL DB caching on network filesystems without probing → Use Linux filesystem type to decide about NSS SQL DB caching and speed measuring
See Also: → 1432484
See Also: → 1444943, 1435376, 1444511
Attached patch 1456888-v2.patchSplinter Review
Attachment #8971162 - Flags: review?(rrelyea)
Attachment #8970910 - Attachment is obsolete: true
The current patch focuses on Linux. I understand the Windows code is still being worked on in 1444511. We could further update the NSS code at a later time, after the Windows logic in Firefox was completed.
Comment on attachment 8971162 [details] [diff] [review]
1456888-v2.patch

Review of attachment 8971162 [details] [diff] [review]:
-----------------------------------------------------------------

The code is correct as is. I've made a few comment you can choose to address or not.

bob

::: lib/softoken/sdb.c
@@ +1953,5 @@
> +                case NFS_SUPER_MAGIC:
> +                    /* We assume these are slow. */
> +                    enableCache = PR_TRUE;
> +                    break;
> +                case AFS_SUPER_MAGIC:

I would expect AFS is actually enableCache=PR_FALSE. AFS does full file caching, which means once you've read the file it's there in your local filesystem, so there isn't a per access cost. OTOH, AFS is rare enough, measuring the output is fine. (actually if you are really sharing the file on AFS, then there is reason to believe sqlite will run into cache consistency issues because AFS doesn't write changes back until close, so it's universally recognized as inappropriate for database access.

@@ +1970,5 @@
> +#endif
> +    }
> +
> +    /* If we have already decided to enable caching, then we don't measure. */
> +    if (!enableCache && measureSpeed) {

Don't need to check for !enableCache. We only set measureSpeed if we haven't dealt with the cache. (that is when we know we want to do the automatic access we always set measureSpeed explicitly, so the !enableCache is a noop).
Attachment #8971162 - Flags: review?(rrelyea) → review+
Thanks for the review. I'll add Bob's requested changes.
Attached patch 1456888-v3.patchSplinter Review
https://hg.mozilla.org/projects/nss/rev/5a210945d248
Target Milestone: --- → 3.38
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.