[vlc-devel] commit: Reduce memory usage (-28%) by packing index structures. ( Laurent Aimar )

git version control git at videolan.org
Mon Nov 17 20:16:45 CET 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Nov 17 19:55:01 2008 +0100| [3fd3d4a872d0f04aa779ffef10ed806b30429a70] | committer: Laurent Aimar 

Reduce memory usage (-28%) by packing index structures.

It is done by using __attribute__((__packed__)) when available.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3fd3d4a872d0f04aa779ffef10ed806b30429a70
---

 src/input/es_out_timeshift.c |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 818c021..d26441a 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -53,6 +53,13 @@
  * Local prototypes
  *****************************************************************************/
 
+/* XXX attribute_packed is (and MUST be) used ONLY to reduce memory usage */
+#ifdef HAVE_ATTRIBUTE_PACKED
+#   define attribute_packed __attribute__((__packed__))
+#else
+#   define attribute_packed
+#endif
+
 enum
 {
     C_ADD,
@@ -61,25 +68,25 @@ enum
     C_CONTROL,
 };
 
-typedef struct
+typedef struct attribute_packed
 {
     es_out_id_t *p_es;
     es_format_t *p_fmt;
 } ts_cmd_add_t;
 
-typedef struct
+typedef struct attribute_packed
 {
     es_out_id_t *p_es;
 } ts_cmd_del_t;
 
-typedef struct
+typedef struct attribute_packed
 {
     es_out_id_t *p_es;
     block_t *p_block;
-    off_t i_offset;
+    int     i_offset;  /* We do not use file > INT_MAX */
 } ts_cmd_send_t;
 
-typedef struct
+typedef struct attribute_packed
 {
     int  i_query;
 
@@ -117,9 +124,9 @@ typedef struct
     };
 } ts_cmd_control_t;
 
-typedef struct
+typedef struct attribute_packed
 {
-    int     i_type;
+    int8_t  i_type;
     mtime_t i_date;
     union
     {
@@ -137,7 +144,7 @@ struct ts_storage_t
 
     /* */
     char    *psz_file;  /* Filename */
-    int64_t i_file_max; /* Max size in bytes */
+    size_t  i_file_max; /* Max size in bytes */
     int64_t i_file_size;/* Current size in bytes */
     FILE    *p_filew;   /* FILE handle for data writing */
     FILE    *p_filer;   /* FILE handle for data reading */
@@ -319,6 +326,16 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out
     p_sys->psz_tmp_path = GetTmpPath( psz_tmp_path );
     msg_Dbg( p_input, "using timeshift  path '%s'", p_sys->psz_tmp_path );
 
+#if 0
+#define S(t) msg_Err( p_input, "SIZEOF("#t")=%d", sizeof(t) )
+    S(ts_cmd_t);
+    S(ts_cmd_control_t);
+    S(ts_cmd_send_t);
+    S(ts_cmd_del_t);
+    S(ts_cmd_add_t);
+#undef S
+#endif
+
     return p_out;
 }
 




More information about the vlc-devel mailing list