Project

General

Profile

Actions

Optimization #583

closed

improve Packet_ structure layout

Added by Victor Julien over 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Low
Assignee:
Target version:
Effort:
Difficulty:
Label:

Description

struct Packet_ {
        Address                    src;                  /*     0    20 */
        Address                    dst;                  /*    20    20 */
        union {
                Port               sp;                   /*           2 */
                uint8_t            type;                 /*           1 */
        };                                               /*    40     2 */
        union {
                Port               dp;                   /*           2 */
                uint8_t            code;                 /*           1 */
        };                                               /*    42     2 */
        uint8_t                    proto;                /*    44     1 */
        uint8_t                    recursion_level;      /*    45     1 */
        uint16_t                   flags;                /*    46     2 */
        uint8_t                    flowflags;            /*    48     1 */
        uint8_t                    pkt_src;              /*    49     1 */

        /* XXX 6 bytes hole, try to pack */

        struct Flow_ *             flow;                 /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        struct timeval             ts;                   /*    64    16 */
        union {
                AFPPacketVars      afp_v;                /*          32 */
                PcapPacketVars     pcap_v;               /*           0 */
        };                                               /*    80    32 */
        int                        datalink;             /*   112     4 */
        uint8_t                    action;               /*   116     1 */

        /* XXX 3 bytes hole, try to pack */

        int                        debuglog_flowbits_names_len; /*   120     4 */

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 2 boundary (128 bytes) --- */
        const char  * *            debuglog_flowbits_names; /*   128     8 */
        TmEcode                    (*ReleaseData)(ThreadVars *, struct Packet_ *); /*   136     8 */
        PktVar *                   pktvar;               /*   144     8 */
        EthernetHdr *              ethh;                 /*   152     8 */
        IPV4Hdr *                  ip4h;                 /*   160     8 */
        IPV4Vars                   ip4vars;              /*   168   736 */
        /* --- cacheline 14 boundary (896 bytes) was 8 bytes ago --- */
        IPV6Hdr *                  ip6h;                 /*   904     8 */
        IPV6Vars                   ip6vars;              /*   912     2 */

        /* XXX 6 bytes hole, try to pack */

        IPV6ExtHdrs                ip6eh;                /*   920   808 */
        /* --- cacheline 27 boundary (1728 bytes) --- */
        TCPHdr *                   tcph;                 /*  1728     8 */
        TCPVars                    tcpvars;              /*  1736   368 */
        /* --- cacheline 32 boundary (2048 bytes) was 56 bytes ago --- */
        UDPHdr *                   udph;                 /*  2104     8 */
        /* --- cacheline 33 boundary (2112 bytes) --- */
        UDPVars                    udpvars;              /*  2112     4 */

        /* XXX 4 bytes hole, try to pack */

        SCTPHdr *                  sctph;                /*  2120     8 */
        ICMPV4Hdr *                icmpv4h;              /*  2128     8 */
        ICMPV4Vars                 icmpv4vars;           /*  2136    64 */
        /* --- cacheline 34 boundary (2176 bytes) was 24 bytes ago --- */
        ICMPV6Hdr *                icmpv6h;              /*  2200     8 */
        ICMPV6Vars                 icmpv6vars;           /*  2208    88 */
        /* --- cacheline 35 boundary (2240 bytes) was 56 bytes ago --- */
        PPPHdr *                   ppph;                 /*  2296     8 */
        /* --- cacheline 36 boundary (2304 bytes) --- */
        PPPOESessionHdr *          pppoesh;              /*  2304     8 */
        PPPOEDiscoveryHdr *        pppoedh;              /*  2312     8 */
        GREHdr *                   greh;                 /*  2320     8 */
        VLANHdr *                  vlanh;                /*  2328     8 */
        uint8_t *                  payload;              /*  2336     8 */
        uint16_t                   payload_len;          /*  2344     2 */

        /* XXX 6 bytes hole, try to pack */

        uint8_t *                  pkt;                  /*  2352     8 */
        uint8_t *                  ext_pkt;              /*  2360     8 */
        /* --- cacheline 37 boundary (2368 bytes) --- */
        uint32_t                   pktlen;               /*  2368     4 */

        /* XXX 4 bytes hole, try to pack */

        struct LiveDevice_ *       livedev;              /*  2376     8 */
        PacketAlerts               alerts;               /*  2384   248 */
        /* --- cacheline 41 boundary (2624 bytes) was 8 bytes ago --- */
        uint64_t                   pcap_cnt;             /*  2632     8 */
        pthread_mutex_t            tunnel_mutex;         /*  2640    40 */
        uint16_t                   tunnel_rtv_cnt;       /*  2680     2 */
        uint16_t                   tunnel_tpr_cnt;       /*  2682     2 */
        PacketEngineEvents         events;               /*  2684    16 */

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 42 boundary (2688 bytes) was 16 bytes ago --- */
        struct Packet_ *           next;                 /*  2704     8 */
        struct Packet_ *           prev;                 /*  2712     8 */
        struct Packet_ *           root;                 /*  2720     8 */
        PktProfiling               profile;              /*  2728  1368 */
        /* --- cacheline 64 boundary (4096 bytes) --- */

        /* size: 4096, cachelines: 64, members: 54 */
        /* sum members: 4059, holes: 8, sum holes: 37 */
};
Actions #1

Updated by Victor Julien over 11 years ago

Seems we can move

       uint8_t                    action;               /*   116     1 */
       int                        debuglog_flowbits_names_len; /*   120     4 */

Into the 6 bytes hole above for example.

Actions #2

Updated by Victor Julien over 11 years ago

Also, pktlen just under payload_len.

Actions #3

Updated by Victor Julien over 11 years ago

  • Priority changed from Normal to Low
Actions #4

Updated by Victor Julien over 11 years ago

  • Target version changed from 1.4beta3 to 1.4rc1
Actions #5

Updated by Victor Julien over 11 years ago

  • Target version changed from 1.4rc1 to 2.0rc2
Actions #6

Updated by Victor Julien over 10 years ago

  • Status changed from New to Assigned
  • Assignee changed from OISF Dev to Ken Steele
Actions #7

Updated by Ken Steele over 10 years ago

  • % Done changed from 0 to 100

Fixed in PR 641.

Actions #8

Updated by Ken Steele over 10 years ago

  • Status changed from Assigned to Closed
Actions #9

Updated by Victor Julien over 10 years ago

  • Target version changed from 2.0rc2 to 2.0beta2
Actions

Also available in: Atom PDF