Changeset eb70703 for lib


Ignore:
Timestamp:
11/14/17 11:31:09 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
07de3c6
Parents:
5d8280a
Message:

Only initialise mmsgbufs when we're actually going to use them.

Previous change meant that we aren't going to be actually calling
recvmmsg so stop wasting time repeatedly initialising buffers that
aren't going to be used.

Also moved initialisation of mmsgbuf fields that do not change
out of the per-packet path so we don't end up repeatedly setting
values to the same thing that they were before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_ndag.c

    r5d8280a reb70703  
    698698                ssock->mmsgbufs[i].msg_hdr.msg_iov = (struct iovec *)
    699699                                malloc(sizeof(struct iovec));
     700                ssock->mmsgbufs[i].msg_hdr.msg_name = ssock->srcaddr->ai_addr;
     701                ssock->mmsgbufs[i].msg_hdr.msg_namelen = ssock->srcaddr->ai_addrlen;
     702                ssock->mmsgbufs[i].msg_hdr.msg_control = NULL;
     703                ssock->mmsgbufs[i].msg_hdr.msg_controllen = 0;
     704                ssock->mmsgbufs[i].msg_hdr.msg_flags = 0;
     705                ssock->mmsgbufs[i].msg_len = 1;
    700706        }
    701707
     
    761767}
    762768
    763 static int init_receivers(streamsock_t *ssock) {
     769static void init_receivers(streamsock_t *ssock, int required) {
     770
     771        int wind = ssock->nextwriteind;
     772        int i;
     773
     774        for (i = 0; i < required; i++) {
     775                ssock->mmsgbufs[i].msg_len = 0;
     776                ssock->mmsgbufs[i].msg_hdr.msg_iov->iov_base = ssock->saved[wind];
     777                ssock->mmsgbufs[i].msg_hdr.msg_iov->iov_len = ENCAP_BUFSIZE;
     778                ssock->mmsgbufs[i].msg_hdr.msg_iovlen = 1;
     779
     780                wind ++;
     781        }
     782}
     783
     784static int count_receivers(streamsock_t *ssock) {
    764785
    765786        int wind = ssock->nextwriteind;
     
    776797                        break;
    777798                }
    778 
    779                 ssock->mmsgbufs[i].msg_len = 0;
    780                 ssock->mmsgbufs[i].msg_hdr.msg_name = ssock->srcaddr->ai_addr;
    781                 ssock->mmsgbufs[i].msg_hdr.msg_namelen = ssock->srcaddr->ai_addrlen;
    782                 ssock->mmsgbufs[i].msg_hdr.msg_iov->iov_base = ssock->saved[wind];
    783                 ssock->mmsgbufs[i].msg_hdr.msg_iov->iov_len = ENCAP_BUFSIZE;
    784                 ssock->mmsgbufs[i].msg_hdr.msg_iovlen = 1;
    785                 ssock->mmsgbufs[i].msg_hdr.msg_control = NULL;
    786                 ssock->mmsgbufs[i].msg_hdr.msg_controllen = 0;
    787                 ssock->mmsgbufs[i].msg_hdr.msg_flags = 0;
    788799
    789800                avail ++;
     
    872883        }
    873884
    874         avail = init_receivers(ssock);
     885        avail = count_receivers(ssock);
    875886
    876887        if (avail == 0) {
     
    883894                return 1;
    884895        }
     896
     897        init_receivers(ssock, avail);
    885898
    886899        ret = recvmmsg(ssock->sock, ssock->mmsgbufs, avail,
Note: See TracChangeset for help on using the changeset viewer.