Closed Bug 1581067 Opened 5 years ago Closed 5 years ago

DOM cache leaves many empty sub directories on disk

Categories

(Core :: DOM: Service Workers, defect, P2)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: janv, Assigned: tt)

References

Details

Attachments

(6 files)

I'm working on mitigating shutdown hangs and I noticed that some of the shutdown hangs are caused by slow GetBodyUsage method. I'm going to add a check there that will abort the directory traversal if we are shutting down, but the storage initialization time can be significantly affected by this too. So it would be great if someone could investigate if we can eliminate these empty sub directories.

Here are some statistics from a storage/default directory:
bash-3.2$ find . | wc -l
15992
bash-3.2$ find . -type d | wc -l
7935
bash-3.2$ find . -type d -empty | wc -l
2802
bash-3.2$ find . -type d -empty | grep morgue | wc -l
2145

So if we fix this bug we can expect approximately 14% perf improvement.

Tom, please take a look when you have time.

Flags: needinfo?(shes050117)

Sure

Assignee: nobody → shes050117
Flags: needinfo?(shes050117)
Priority: -- → P2
Attachment #9094160 - Attachment description: Bug 1581067 - WIP; → Bug 1581067 - P1 - Remove the emptry body directory when removing files inside;

Depends on D46586

One note, we might want to remove existing empty directories as part of a minor storage upgrade.

Attachment #9094583 - Attachment is obsolete: true
Attachment #9094583 - Attachment is obsolete: false

(In reply to Jan Varga [:janv] from comment #5)

One note, we might want to remove existing empty directories as part of a minor storage upgrade.

I remember I did that on another bug (not including empty directories on DOM Cache), but with the patch here we could achieve that easily. I'll try to find that.

(moving to at least a bit better component)

Component: DOM: Core & HTML → DOM: Web Storage

Ah, sorry.

Component: DOM: Web Storage → DOM: Service Workers
Status: NEW → ASSIGNED

(In reply to Tom Tung [:tt, :ttung] from comment #6)

(In reply to Jan Varga [:janv] from comment #5)

One note, we might want to remove existing empty directories as part of a minor storage upgrade.

I remember I did that on another bug (not including empty directories on DOM Cache), but with the patch here we could achieve that easily. I'll try to find that.

It's bug 1576593

How bug 1576593 relates to this ?

Depends on D47451

Note: I landed the first two patches since the implementation removes empty directories while accessing the cache origin

Pushed by ttung@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fbfdd8ee1b42 P1 - Remove the emptry body directory when removing files inside; r=asuth https://hg.mozilla.org/integration/autoland/rev/89df3c99bf3b P2 - Extract similar to reuse the code; r=asuth

For the rest two patches.

Keywords: leave-open
Regressions: 1584746
Pushed by ttung@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b7c882c1e3d3 P3 - Suppress the error reuslt for open stream; r=asuth https://hg.mozilla.org/integration/autoland/rev/e7a90d8f615d P4 - Add a test to verify the result; r=asuth

Backed out 2 changesets (bug 1581067) for xpcshell failures at dom/cache/test/xpcshell/test_empty_directories.js

Backout: https://hg.mozilla.org/integration/autoland/rev/5d83a502d367de1332ceb234275416f315328340

Failure push: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=e7a90d8f615d7902d127febd00e5c2231cbef5ee

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=269026867&repo=autoland&lineNumber=2582

[task 2019-09-30T11:26:33.643Z] 11:26:33 INFO - TEST-START | dom/cache/test/xpcshell/test_empty_directories.js
[task 2019-09-30T11:26:33.965Z] 11:26:33 WARNING - TEST-UNEXPECTED-FAIL | dom/cache/test/xpcshell/test_empty_directories.js | xpcshell return code: 0
[task 2019-09-30T11:26:33.966Z] 11:26:33 INFO - TEST-INFO took 319ms
[task 2019-09-30T11:26:33.966Z] 11:26:33 INFO - >>>>>>>
[task 2019-09-30T11:26:33.967Z] 11:26:33 INFO - PID 13221 | [13221, Main Thread] WARNING: Couldn't get the user appdata directory. Crash events may not be produced.: file /builds/worker/workspace/build/src/toolkit/crashreporter/nsExceptionHandler.cpp, line 2632
[task 2019-09-30T11:26:33.968Z] 11:26:33 INFO - PID 13221 | Couldn't convert chrome URL: chrome://branding/locale/brand.properties
[task 2019-09-30T11:26:33.968Z] 11:26:33 INFO - PID 13221 | [13221, Main Thread] WARNING: NSS will be initialized without a profile directory. Some things may not work as expected.: file /builds/worker/workspace/build/src/security/manager/ssl/nsNSSComponent.cpp, line 1342
[task 2019-09-30T11:26:33.969Z] 11:26:33 INFO - (xpcshell/head.js) | test MAIN run_test pending (1)
[task 2019-09-30T11:26:33.970Z] 11:26:33 INFO - (xpcshell/head.js) | test pending (2)
[task 2019-09-30T11:26:33.970Z] 11:26:33 INFO - "Setting up environment"
[task 2019-09-30T11:26:33.971Z] 11:26:33 INFO - PID 13221 | [13221, Main Thread] WARNING: '!window', file /builds/worker/workspace/build/src/dom/cache/CacheStorage.cpp, line 575
[task 2019-09-30T11:26:33.971Z] 11:26:33 INFO - (xpcshell/head.js) | test MAIN run_test finished (2)
[task 2019-09-30T11:26:33.972Z] 11:26:33 INFO - running event loop
[task 2019-09-30T11:26:33.973Z] 11:26:33 INFO - PID 13221 | [13221, Main Thread] WARNING: Could not get the program name for a cubeb stream.: 'NS_SUCCEEDED(rv)', file /builds/worker/workspace/build/src/dom/media/CubebUtils.cpp, line 384
[task 2019-09-30T11:26:33.973Z] 11:26:33 INFO - "CONSOLE_MESSAGE: (info) No chrome package registered for chrome://branding/locale/brand.properties"
[task 2019-09-30T11:26:33.973Z] 11:26:33 INFO - "Test 0 - InitOrigin shouldn't leave an empty directoy"
[task 2019-09-30T11:26:33.974Z] 11:26:33 INFO - PID 13221 | [13221, Main Thread] WARNING: '!window', file /builds/worker/workspace/build/src/dom/cache/CacheStorage.cpp, line 575

Flags: needinfo?(ttung)

(In reply to Cristina Coroiu [:ccoroiu] from comment #19)
Sorry for this, but I cannot reproduce it on my desktop (ubuntu). I might need to log more info on try

Flags: needinfo?(ttung)

Just discussed with Jan if we need this on a storage upgrade. We don't need to clear the empty cache directories on a storage upgrade, because we would trigger InitOrigin once build-id changes and that would remove the empty morgue directory.

So, the nsID value is not reliable for the test I wrote. The body directory is the last two number of the nsID (or some other way to hash the value). There are two body directories/files and I assumed the first one always collides with the cache.put(testURL). And it actually work on my mac and ubuntu, but the later one collides with that on the try server.

I should just ensure that the morgue folder won't be empty.

I rewrote the test and will ask for the review again if the try goes green
try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=ea3d9a12b816f6fdc3333713c64441dc8edb0d58

IIUC, P5 should fix the bug 1584746

Pushed by ttung@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d34125d9dba3 P3 - Suppress the error reuslt for open stream; r=asuth https://hg.mozilla.org/integration/autoland/rev/0a3fd8b7865a P4 - Add a test to verify the result; r=asuth https://hg.mozilla.org/integration/autoland/rev/74d480f1bfa8 P5 - Only remove the temporary body files & body directories when it's in the initializing stage; r=asuth https://hg.mozilla.org/integration/autoland/rev/d87f43669456 P6 - Change the test due to P5; r=asuth
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Keywords: leave-open
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: