On Wed, Mar 21, 2018 at 04:59:19PM +0100, Duy Nguyen wrote:
> About the 16k limit (and some other limits as well), I'm making these
> patches with the assumption that large scale deployment probably will
> go with custom builds anyway. Adjusting the limits back should be
> quite easy while we can still provide reasonable defaults for most
> people.

And we could even do something like this to make custom builds
easier. Some more gluing is needed so you can set this from config.mak
but you get the idea. This removes all limits set by this
series. Readability in pack-objects.c and object_entry struct
declaration is still a concern though.

-- 8< --
diff --git a/pack-objects.h b/pack-objects.h
index af40211105..b6e84c9b48 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -2,10 +2,17 @@
 #define PACK_OBJECTS_H
 
 #define OE_DFS_STATE_BITS      2
+#ifdef PACK_OBJECTS_BIG_MEMORY
+#define OE_DEPTH_BITS          31
+/* OE_IN_PACK_BITS is not defined */
+#define OE_Z_DELTA_BITS                32
+#define OE_DELTA_SIZE_BITS     32
+#else
 #define OE_DEPTH_BITS          12
 #define OE_IN_PACK_BITS                14
 #define OE_Z_DELTA_BITS                16
 #define OE_DELTA_SIZE_BITS     31
+#endif
 
 /*
  * State flags for depth-first search used for analyzing delta cycles.
@@ -82,7 +89,11 @@ struct object_entry {
                                     */
        uint32_t delta_size_:OE_DELTA_SIZE_BITS; /* delta data size 
(uncompressed) */
        uint32_t delta_size_valid:1;
+#ifdef PACK_OBJECTS_BIG_MEMORY
+       struct packed_git *in_pack; /* already in pack */
+#else
        unsigned in_pack_idx:OE_IN_PACK_BITS;   /* already in pack */
+#endif
        unsigned size_valid:1;
        unsigned z_delta_size:OE_Z_DELTA_BITS;
        unsigned type_valid:1;
@@ -112,7 +123,9 @@ struct packing_data {
 
        unsigned int *in_pack_pos;
        int in_pack_count;
+#ifndef PACK_OBJECTS_BIG_MEMORY
        struct packed_git *in_pack[1 << OE_IN_PACK_BITS];
+#endif
 };
 
 struct object_entry *packlist_alloc(struct packing_data *pdata,
@@ -174,6 +187,9 @@ static inline void oe_set_in_pack_pos(const struct 
packing_data *pack,
 static inline unsigned int oe_add_pack(struct packing_data *pack,
                                       struct packed_git *p)
 {
+#ifdef PACK_OBJECTS_BIG_MEMORY
+       return 0;
+#else
        if (pack->in_pack_count >= (1 << OE_IN_PACK_BITS))
                die(_("too many packs to handle in one go. "
                      "Please add .keep files to exclude\n"
@@ -187,22 +203,31 @@ static inline unsigned int oe_add_pack(struct 
packing_data *pack,
        }
        pack->in_pack[pack->in_pack_count] = p;
        return pack->in_pack_count++;
+#endif
 }
 
 static inline struct packed_git *oe_in_pack(const struct packing_data *pack,
                                            const struct object_entry *e)
 {
+#ifdef PACK_OBJECTS_BIG_MEMORY
+       return e->in_pack;
+#else
        return pack->in_pack[e->in_pack_idx];
+#endif
 
 }
 
 static inline void oe_set_in_pack(struct object_entry *e,
                                  struct packed_git *p)
 {
+#ifdef PACK_OBJECTS_BIG_MEMORY
+       e->in_pack = p;
+#else
        if (p->index <= 0)
                die("BUG: found_pack should be NULL "
                    "instead of having non-positive index");
        e->in_pack_idx = p->index;
+#endif
 
 }
 
-- 8< --

Reply via email to