]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Reorder 'inflate_state' struct to improve cache-locality of variables
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Wed, 25 Sep 2024 15:25:19 +0000 (17:25 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 8 Oct 2024 13:51:12 +0000 (15:51 +0200)
needed by inffast (from 6 cachelines to 1).
Also fill in some unnecessary holes.

inflate.h

index 66e6129d28e2201eccb65f645a13e62795dd6a4c..f3bede2e414216b06576a668cedb42e21b4341d5 100644 (file)
--- a/inflate.h
+++ b/inflate.h
@@ -97,7 +97,7 @@ typedef struct inflate_allocs_s {
 /* State maintained between inflate() calls -- approximately 7K bytes, not
    including the allocated sliding window, which is up to 32K bytes. */
 struct ALIGNED_(64) inflate_state {
-    PREFIX3(stream) *strm;             /* pointer back to this zlib stream */
+    PREFIX3(stream) *strm;      /* pointer back to this zlib stream */
     inflate_mode mode;          /* current inflate mode */
     int last;                   /* true if processing last block */
     int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip,
@@ -105,9 +105,12 @@ struct ALIGNED_(64) inflate_state {
     int havedict;               /* true if dictionary provided */
     int flags;                  /* gzip header method and flags, 0 if zlib, or
                                    -1 if raw or no header yet */
+    unsigned was;               /* initial length of match, for inflateMark */
     unsigned long check;        /* protected copy of check value */
     unsigned long total;        /* protected copy of output count */
     PREFIX(gz_headerp) head;    /* where to save gzip header information */
+    int back;                   /* bits back of last unprocessed length/lit */
+
         /* sliding window */
     unsigned wbits;             /* log base 2 of requested window size */
     uint32_t wsize;             /* window size or zero if not using window */
@@ -115,39 +118,37 @@ struct ALIGNED_(64) inflate_state {
     uint32_t whave;             /* valid bytes in the window */
     uint32_t wnext;             /* window write index */
     unsigned char *window;      /* allocated sliding window, if needed */
-#if defined(_M_IX86) || defined(_M_ARM)
-    uint32_t padding;
-#else
-    uint32_t padding[2];
-#endif
-
-    struct crc32_fold_s ALIGNED_(16) crc_fold;
+    uint32_t chunksize;         /* size of memory copying chunk */
 
         /* bit accumulator */
     uint32_t hold;              /* input bit accumulator */
     unsigned bits;              /* number of bits in "in" */
+        /* fixed and dynamic code tables */
+    unsigned lenbits;           /* index bits for lencode */
+    code const *lencode;        /* starting table for length/literal codes */
+    code const *distcode;       /* starting table for distance codes */
+    unsigned distbits;          /* index bits for distcode */
         /* for string and stored block copying */
     uint32_t length;            /* literal or length of data to copy */
     unsigned offset;            /* distance back to copy string from */
         /* for table and code decoding */
     unsigned extra;             /* extra bits needed */
-        /* fixed and dynamic code tables */
-    code const *lencode;        /* starting table for length/literal codes */
-    code const *distcode;       /* starting table for distance codes */
-    unsigned lenbits;           /* index bits for lencode */
-    unsigned distbits;          /* index bits for distcode */
         /* dynamic table building */
     unsigned ncode;             /* number of code length code lengths */
     unsigned nlen;              /* number of length code lengths */
     unsigned ndist;             /* number of distance code lengths */
     uint32_t have;              /* number of code lengths in lens[] */
     code *next;                 /* next available space in codes[] */
+
+#if defined(_M_IX86) || defined(_M_ARM)
+    uint32_t padding[2];
+#endif
+    struct crc32_fold_s ALIGNED_(16) crc_fold;
+
     uint16_t lens[320];         /* temporary storage for code lengths */
     uint16_t work[288];         /* work area for code table building */
     code codes[ENOUGH];         /* space for code tables */
-    int back;                   /* bits back of last unprocessed length/lit */
-    unsigned was;               /* initial length of match */
-    uint32_t chunksize;         /* size of memory copying chunk */
+
     inflate_allocs *alloc_bufs; /* struct for handling memory allocations */
 
 #ifdef INFLATE_STRICT