Monday, June 15, 2009

Alternate page sizes in InnoDB

InnoDB supports multiple page sizes. The default page size is 16kb and compiled into the binary/plugin. The valid page sizes are 8kb, 16kb, 32kb and 64kb. However, there is a known bug for page sizes > 16kb with row_format=COMPACT. Also, there are few deployments with a page size other than 16kb, so the amazing reliability of InnoDB may degrade for other page sizes until the bugs are found and fixed.

To use an alternate page size, edit innobase/include/univ.i to change these:
/* The universal page size of the database */
#define UNIV_PAGE_SIZE          (2 * 8192)
/* The 2-logarithm of UNIV_PAGE_SIZE: */
#define UNIV_PAGE_SIZE_SHIFT    14
Does InnoDB support 4kb pages? Maybe. If you edit the fields listed above for a 4kb page size and run MySQL, you will quickly get a core dump. The problem is that there are other per-page objects that are too big for a 4kb page. The first problem I encountered is fixed by editing innobase/include/trx0rseg.h to reduce the number of rollback segment slots per page. The default value is:
#define TRX_RSEG_N_SLOTS    1024
To be really safe, I set it to 256 and the segfault was fixed. I haven't done testing beyond this so your mileage may vary.

InnoDB had a 900 byte per-page overhead when I last measured this. 900 bytes per 4kb page is much worse than per 16kb page. I am not sure when this will get fixed.

5 comments:

  1. Do you actually want smaller/other page sizes, or just curious?
    IIRC peterz tried 64k pages and decided it wasn't worth it, performance wise.

    ReplyDelete
  2. I want smaller pages for disk-bound OLTP workloads. This should provide a moderate benefit with SATA and a larger benefit with Intel SSD. To confirm I will test on SATA soon. Alas, I don't have an Intel SSD yet.

    ReplyDelete
  3. Small pages will decrease the performance of index scans (but not lookups), but should increase efficiency of the buffer cache. It can also decrease page/block contention but I don't know if it is an issue with InnoDB.

    ReplyDelete
  4. The workload for which I want to try this is extremely IO bound with mostly index lookups and few scans.

    ReplyDelete
  5. Mark, we need to get you an intel SSD ... :)

    I too compiled with 4k pages to test... With SSD there might be a performance boost here.

    Though 900 byte overhead could be improved.

    Also, making this a configurable might help find bugs sooner...

    ReplyDelete

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.