On 16/11/2011 02:54, Nicholas Nethercote wrote:
>> E) Places optimizations:
I'd prefer calling this Storage optimizations, Places is just one of the
many users, and some of those don't even try to avoid mainthread IO
(that luckily Places does regarding history and favicons, not bookmarks
yet). All users should be fixed, included the Storage API (bug 699820)
> Some people clearly don't like SQLite at all, and would simply like it to be
> removed from Firefox. (It's already been removed from Fennec).
This is partly untrue, I think the Android system history and
bookmarking stuff, that is being used as a Places replacement, is just
another SQLite database, based on an older version of SQLite (depending
on what the system has available). And I don't know if it's doing
mainthread IO, nor nobody measured it being faster as far as I can tell.
It may be, since it's likely simpler, as well as we may go simpler (and
we are doing).
> I can see and understand one clear complaint: SQLite uses too much memory.
To be clear, for a long time this was done "by design". Probably a bad
decision in the past. The current code in nightly has removed most of
those bad decisions and we are down to "acceptable" (but still
improvable, see below) levels.
> The slow-down associated with this was only
> 5--10% on SQLite performance tests, but it's unclear how those correlate to
> Firefox's SQLite performance.
Right, this should be measured, the issue we may hit is an increase in
the number of disk reads. Though it's possible our usecase may not reuse
pages that much, and we'd not see any tangible perf hit.
This can be measured using xperf or any other profiler to count disk
reads, maybe during a Tp5 test run.
----
There is also another possibility to reduce memory, that is avoding slop
bytes in pages allocations (10% to 50% win), but this has a cost
involved in:
- 1 additional malloc per page alloc
- 1 additional page boundaries check
The performance cost of this has been evaluated in about 3%, mostly due
to the boundaries check. The problem is that for certain database
corruptions SQLite may try to read some bytes after the end of a page,
and this is a problem when those fall out of the mapped space.
To alleviate the problem SQLite allocs page+header so that the over-read
bytes fall into the header and never out of mapped space.
If we could provide a jemalloc way to add some padding to certain
allocations or to do 2 separate allocations but ensure one follows the
other one, this may be solved with no perf penalty.
Otherwise we may try to help optimizing the boundaries check code, that
you can find in sqlite.c between the SQLITE_OVERSIZE_CELL_CHECK defines.
Any help or ideas about this would be appreciated.
> SQLite also has the ability to drop lots of memory on request, so long as
> the requests are made per-connection.
And this would be really useful to solve the memory-pressure problem
(bug 411894). We can use it, we could not in the past due to
SQLITE_MEMORY_MANAGEMENT being particularly expensive in threadsafe
mode, but Richard said this new api would not be expensive, it should
just be invoked by each thread.
> Another issue relating to SQLite -- we've only ever used official SQLite
> releases in Firefox, and never modified them. Richard suggested we might
> like to consider taking unmodified revisions from the SQLite repository.
> These obviously are uniquely identifiable. The advantage is that we could
> get any improvements into Firefox without having to wait for the SQLite
> release cycle. Are there any objections to doing this?
I think the main objection from the past was that we should not make
SQLite updates harder. So we likely won't take internal patches (we
should send them to the SQLite team instead), but imo we may take
special versions from them even if those are not officially released.
But Sdwilsh is the module owner here, so this should go through him, I'm
only giving my personal opinion.
Cheers,
Marco