• R/O
  • SSH

GM: Commit

Main GraphicsMagick source repository


Commit MetaInfo

Revisióncedbb6f8bc14497c21ac373b585d8c51434e48cd (tree)
Tiempo2021-06-06 00:30:40
AutorBob Friesenhahn <bfriesen@Grap...>
CommiterBob Friesenhahn

Log Message

Managed-memory: Round up allocation size on small reallocs in order to lessen the number of actual reallocs.

Cambiar Resumen

Diferencia incremental

diff -r be4c176bbb05 -r cedbb6f8bc14 ChangeLog
--- a/ChangeLog Mon May 31 14:35:55 2021 -0500
+++ b/ChangeLog Sat Jun 05 10:30:40 2021 -0500
@@ -1,3 +1,9 @@
1+2021-06-05 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
2+
3+ * magick/memory.c (_MagickReallocateResourceLimitedMemory): Round
4+ up allocation size on small reallocs in order to lessen the number
5+ of actual reallocs.
6+
17 2021-05-31 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
28
39 * coders/svg.c (SVGComment): Re-implement comment callback to be based on
diff -r be4c176bbb05 -r cedbb6f8bc14 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx Mon May 31 14:35:55 2021 -0500
+++ b/VisualMagick/installer/inc/version.isx Sat Jun 05 10:30:40 2021 -0500
@@ -10,5 +10,5 @@
1010
1111 #define public MagickPackageName "GraphicsMagick"
1212 #define public MagickPackageVersion "1.4"
13-#define public MagickPackageVersionAddendum ".020210531"
14-#define public MagickPackageReleaseDate "snapshot-20210531"
13+#define public MagickPackageVersionAddendum ".020210605"
14+#define public MagickPackageReleaseDate "snapshot-20210605"
diff -r be4c176bbb05 -r cedbb6f8bc14 magick/memory.c
--- a/magick/memory.c Mon May 31 14:35:55 2021 -0500
+++ b/magick/memory.c Sat Jun 05 10:30:40 2021 -0500
@@ -729,9 +729,19 @@
729729 if (new_size > memory_resource.alloc_size_real)
730730 {
731731 void *realloc_memory;
732- /* FIXME: Maybe over-allocate here if re-alloc? */
732+ size_t realloc_size = new_size+sizeof(MagickMemoryResource_T);
733+ /*
734+ If this is a realloc, then round up underlying
735+ allocation sizes for small allocations in order to
736+ lessen realloc calls and lessen memory moves.
737+ */
738+ if ((memory_resource.alloc_size_real != 0) && (realloc_size < 131072))
739+ {
740+ /* realloc_size <<= 1; */
741+ MagickRoundUpStringLength(realloc_size);
742+ }
733743 realloc_memory = (ReallocFunc)(memory_resource.memory,
734- new_size+sizeof(MagickMemoryResource_T));
744+ realloc_size);
735745 if (realloc_memory != 0)
736746 {
737747 if (clear)
@@ -745,7 +755,7 @@
745755 memory_resource.num_realloc_moves++;
746756 memory_resource.memory = realloc_memory;
747757 memory_resource.alloc_size = new_size;
748- memory_resource.alloc_size_real = new_size;
758+ memory_resource.alloc_size_real = realloc_size-sizeof(MagickMemoryResource_T);
749759 }
750760 else
751761 {
diff -r be4c176bbb05 -r cedbb6f8bc14 magick/utility-private.h
--- a/magick/utility-private.h Mon May 31 14:35:55 2021 -0500
+++ b/magick/utility-private.h Sat Jun 05 10:30:40 2021 -0500
@@ -39,21 +39,23 @@
3939
4040 /*
4141 Compute a value which is the next kilobyte power of 2 larger than
42- the requested value or MaxTextExtent, whichever is larger.
42+ the requested value or 256 whichever is larger.
4343
4444 The objective is to round up the size quickly (and in repeatable
4545 steps) in order to reduce the number of memory copies due to realloc
4646 for strings which grow rapidly, while producing a reasonable size
4747 for smaller strings.
4848 */
49-#define MagickRoundUpStringLength(size) \
50-{ \
51- size_t \
52- _rounded; \
53- \
54- for (_rounded=256U; _rounded < (Max(size,256)); _rounded *= 2); \
55- size=_rounded; \
56-}
49+#define MagickRoundUpStringLength(size) \
50+ do { \
51+ size_t \
52+ _rounded, \
53+ _target; \
54+ \
55+ _target=(Max(size,256)); \
56+ for (_rounded=256U; _rounded < _target; _rounded *= 2); \
57+ size=_rounded; \
58+} while(0)
5759
5860 /*
5961 * Local Variables:
diff -r be4c176bbb05 -r cedbb6f8bc14 magick/version.h
--- a/magick/version.h Mon May 31 14:35:55 2021 -0500
+++ b/magick/version.h Sat Jun 05 10:30:40 2021 -0500
@@ -38,8 +38,8 @@
3838 #define MagickLibVersion 0x252200
3939 #define MagickLibVersionText "1.4"
4040 #define MagickLibVersionNumber 25,22,0
41-#define MagickChangeDate "20210531"
42-#define MagickReleaseDate "snapshot-20210531"
41+#define MagickChangeDate "20210605"
42+#define MagickReleaseDate "snapshot-20210605"
4343
4444 /*
4545 The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r be4c176bbb05 -r cedbb6f8bc14 www/Changelog.html
--- a/www/Changelog.html Mon May 31 14:35:55 2021 -0500
+++ b/www/Changelog.html Sat Jun 05 10:30:40 2021 -0500
@@ -35,6 +35,11 @@
3535 <div class="document">
3636
3737
38+<p>2021-06-05 Bob Friesenhahn &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
39+<blockquote>
40+* magick/memory.c (_MagickReallocateResourceLimitedMemory): Round
41+up allocation size on small reallocs in order to lessen the number
42+of actual reallocs.</blockquote>
3843 <p>2021-05-31 Bob Friesenhahn &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
3944 <blockquote>
4045 <p>* coders/svg.c (SVGComment): Re-implement comment callback to be based on
diff -r be4c176bbb05 -r cedbb6f8bc14 www/api/memory.html
--- a/www/api/memory.html Mon May 31 14:35:55 2021 -0500
+++ b/www/api/memory.html Sat Jun 05 10:30:40 2021 -0500
@@ -3,7 +3,7 @@
33 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
44 <head>
55 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-<meta name="generator" content="Docutils 0.16: http://docutils.sourceforge.net/" />
6+<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
77 <title>memory</title>
88 <link rel="stylesheet" href="../docutils-api.css" type="text/css" />
99 </head>
@@ -37,7 +37,7 @@
3737 <h2 class="subtitle" id="memory-allocation-deallocation-functions">Memory allocation/deallocation functions</h2>
3838
3939 <div class="contents topic" id="contents">
40-<p class="topic-title">Contents</p>
40+<p class="topic-title first">Contents</p>
4141 <ul class="simple">
4242 <li><a class="reference internal" href="#magickallocfunctions" id="id15">MagickAllocFunctions</a></li>
4343 <li><a class="reference internal" href="#magickmalloc" id="id16">MagickMalloc</a></li>
Show on old repository browser