Open Bug 1143308 Opened 9 years ago Updated 1 year ago

Use SQLite's mmap'ed I/O mode for IndexedDB

Categories

(Core :: Storage: IndexedDB, defect, P3)

defect

Tracking

()

People

(Reporter: bent.mozilla, Unassigned)

Details

Attachments

(1 file)

Attached patch Patch, v1Splinter Review
This gives us some speed wins in my perf testing. Talked about the risks with sicking and he's ok with them. Details at https://www.sqlite.org/mmap.html
Attachment #8577618 - Flags: review?(Jan.Varga)
I was under the impression that especially on 32-bit windows we're experiencing address space shortages and fragmentation problems, especially with video card drivers doing video memory mmaps in our address space.  Maybe it'd be a good idea to check on dev-platform if this is something that should only be enabled when we're running 64-bit for desktop builds?
Comment on attachment 8577618 [details] [diff] [review]
Patch, v1

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

Do you know how it affects quota handling ?
(In reply to Andrew Sutherland [:asuth] from comment #1)
> should only be enabled when we're running 64-bit for desktop builds?

Yeah, this could be 64bit only.

(In reply to Jan Varga [:janv] from comment #2)
> Do you know how it affects quota handling ?

It doesn't, this all happens below our quota VFS layer.
Attachment #8577618 - Flags: review?(Jan.Varga) → review+
"An I/O error on a memory-mapped file cannot be caught and dealt with by SQLite. Instead, the I/O error causes a signal which, if not caught by the application, results in a program crash."

What kind of IO errors are we talking here?  Is it something as mundane as sqlite wanted to remove a temp file, but windows has it locked?
No, this is about the way POSIX deals with mmap'd I/O errors via the SIGBUS signal.
There's a Windows flavor of the problem too, but it's still just about I/O errors reading/writing a mapped file.
Comment on attachment 8577618 [details] [diff] [review]
Patch, v1

SQLite has a Windows bug in mmap mode where database size isn't set correctly in xTruncate, which causes our quota handling to go haywire. This will need to wait for a SQLite fix.
Attachment #8577618 - Flags: review+
Priority: -- → P3

(In reply to Ben Turner (not reading bugmail, use the needinfo flag!) from comment #7)

Comment on attachment 8577618 [details] [diff] [review]
Patch, v1

SQLite has a Windows bug in mmap mode where database size isn't set
correctly in xTruncate, which causes our quota handling to go haywire. This
will need to wait for a SQLite fix.

Has this SQLite bug been fixed in the meantime? I couldn't find any related issue in the SQLite issue tracker.

Flags: needinfo?(jvarga)

We can try this again, but we need to be careful. Also, it would be good to do some preliminary performance testing and see if this actually has any significant effect on performance. I know the comment 0 says there are some perf wins, but that was 5 years ago. If there's now only negligible improvement it's not worth the hassle with handling I/O errors and quota tracking. There might be differences in mmap perf across platforms (or specific problems happening only on some platforms), in that case we would enable it on some platforms only.
Also, we might need to write new tests for quota tracking to be 100% sure it's safe to enable mmap.

Flags: needinfo?(jvarga)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: