Skip to content
This repository was archived by the owner on Nov 2, 2021. It is now read-only.
This repository was archived by the owner on Nov 2, 2021. It is now read-only.

potential performance issue with packed structs #4

@leifwalsh

Description

@leifwalsh

You say your in-memory objects look like this:

struct itemx {
  STAILQ_ENTRY(itemx) tqe;    /* link in index / free q */
  uint8_t             md[20]; /* sha1 message digest */
  uint32_t            sid;    /* owner slab id */
  uint32_t            offset; /* item offset from owner slab base */
  uint64_t            cas;    /* cas */
} __attribute__ ((__packed__));

I suggest you do not pack these, and that you put cas first. I have seen very bad performance doing atomic ops on fields that cross a cache line boundary, and here you presumably do atomic ops on cas, which is only 4-byte aligned. Depending where itemx is used (and particularly if you ever allocate an array of itemx), you may see strange behavior. See http://www.tokutek.com/2012/12/packing-for-the-holidays/ for some benchmarks.

Unless, of course, you deal with this elsewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions