summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-01-12 02:41:50 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-01-12 03:02:43 +0900
commitfb048e73120b39095cc87aa4f8d7f3d397a93c56 (patch)
tree59b519d5b1b1e8a41e9f3f0d3fce76aa3734c4cf
parent075b14d53f18ef68f52061d5d7dda54d1470532c (diff)
evas sw generic - don't dlopen osmesa until first needed.
osmesa needs llvm. llvm apparently just by dlopening or linking to the lib (libLLVM...) gets you 3.5mb of dirty pages just in this lib. that's a whole lib entirely dirty pages. odd and horrible. in fact once i stoppd dlopening OSMesa all the time on engine init (and only when gl is needed)... the amount of dirty pages went from 17208 to 8860. that's a whopping drop of 8mb! 8mb saved! in fact just dlopening osmesa and doing the other gl init stuff led to more anonymuse mappings with dirty pages. 2 of them (2072k and 2076k) which baffled me as that didn't seem like heap or efl's own data. these disappeared along with libLLVM-5.0.so (3520k + 60k dirty pages). we stopped linking/loading libedit (12k dirty), libglapi (20k dirty), libLLVM-5.0 (3580k dirty), libncursesw (72k dirty), libOSMesa.so (260k dirty), libtinfo (20k dirty). ... or at least stopped until absolutely needed. total 17208k of dirty pages went down to 8860. my test case was just launching terminology (and doing nothing with it). @fix memory bloating
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c80
1 files changed, 52 insertions, 28 deletions
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 139ccc1a1c..209ce71dbe 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -3461,6 +3461,13 @@ _tls_check(void)
3461} 3461}
3462#endif 3462#endif
3463 3463
3464static inline int
3465_check_gl(void)
3466{
3467 if (!gl_lib_init()) return 0;
3468 return 1;
3469}
3470
3464static void * 3471static void *
3465eng_gl_surface_create(void *data EINA_UNUSED, void *config, int w, int h) 3472eng_gl_surface_create(void *data EINA_UNUSED, void *config, int w, int h)
3466{ 3473{
@@ -3468,6 +3475,8 @@ eng_gl_surface_create(void *data EINA_UNUSED, void *config, int w, int h)
3468 Render_Engine_GL_Surface *sfc; 3475 Render_Engine_GL_Surface *sfc;
3469 Evas_GL_Config *cfg; 3476 Evas_GL_Config *cfg;
3470 3477
3478 if (!_check_gl()) return NULL;
3479
3471 sfc = calloc(1, sizeof(Render_Engine_GL_Surface)); 3480 sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
3472 if (!sfc) return NULL; 3481 if (!sfc) return NULL;
3473 3482
@@ -3568,6 +3577,8 @@ eng_gl_surface_destroy(void *data EINA_UNUSED, void *surface)
3568#ifdef EVAS_GL 3577#ifdef EVAS_GL
3569 Render_Engine_GL_Surface *sfc; 3578 Render_Engine_GL_Surface *sfc;
3570 3579
3580 if (!_check_gl()) return 0;
3581
3571 sfc = (Render_Engine_GL_Surface*)surface; 3582 sfc = (Render_Engine_GL_Surface*)surface;
3572 3583
3573 if (!sfc) return 0; 3584 if (!sfc) return 0;
@@ -3598,11 +3609,7 @@ eng_gl_context_create(void *data EINA_UNUSED, void *share_context, int version,
3598 Render_Engine_GL_Context *ctx; 3609 Render_Engine_GL_Context *ctx;
3599 Render_Engine_GL_Context *share_ctx; 3610 Render_Engine_GL_Context *share_ctx;
3600 3611
3601 if (!_tls_check() && !gl_lib_init()) 3612 if (!_check_gl()) return NULL;
3602 {
3603 WRN("Failed to initialize Evas GL (with OSMesa)");
3604 return NULL;
3605 }
3606 3613
3607 if (version != EVAS_GL_GLES_2_X) 3614 if (version != EVAS_GL_GLES_2_X)
3608 { 3615 {
@@ -3648,6 +3655,8 @@ eng_gl_context_destroy(void *data EINA_UNUSED, void *context)
3648#ifdef EVAS_GL 3655#ifdef EVAS_GL
3649 Render_Engine_GL_Context *ctx; 3656 Render_Engine_GL_Context *ctx;
3650 3657
3658 if (!_check_gl()) return 0;
3659
3651 ctx = (Render_Engine_GL_Context*)context; 3660 ctx = (Render_Engine_GL_Context*)context;
3652 3661
3653 if (!ctx) return 0; 3662 if (!ctx) return 0;
@@ -3677,6 +3686,8 @@ eng_gl_make_current(void *data EINA_UNUSED, void *surface, void *context)
3677 OSMesaContext share_ctx; 3686 OSMesaContext share_ctx;
3678 GLboolean ret; 3687 GLboolean ret;
3679 3688
3689 if (!_check_gl()) return 0;
3690
3680 sfc = (Render_Engine_GL_Surface*)surface; 3691 sfc = (Render_Engine_GL_Surface*)surface;
3681 ctx = (Render_Engine_GL_Context*)context; 3692 ctx = (Render_Engine_GL_Context*)context;
3682 3693
@@ -3760,6 +3771,8 @@ static void *
3760eng_gl_proc_address_get(void *data EINA_UNUSED, const char *name) 3771eng_gl_proc_address_get(void *data EINA_UNUSED, const char *name)
3761{ 3772{
3762#ifdef EVAS_GL 3773#ifdef EVAS_GL
3774 if (!_check_gl()) return NULL;
3775
3763 if (_sym_OSMesaGetProcAddress) return _sym_OSMesaGetProcAddress(name); 3776 if (_sym_OSMesaGetProcAddress) return _sym_OSMesaGetProcAddress(name);
3764 return dlsym(RTLD_DEFAULT, name); 3777 return dlsym(RTLD_DEFAULT, name);
3765#else 3778#else
@@ -3775,6 +3788,8 @@ eng_gl_native_surface_get(void *data EINA_UNUSED, void *surface, void *native_su
3775 Render_Engine_GL_Surface *sfc; 3788 Render_Engine_GL_Surface *sfc;
3776 Evas_Native_Surface *ns; 3789 Evas_Native_Surface *ns;
3777 3790
3791 if (!_check_gl()) return 0;
3792
3778 sfc = (Render_Engine_GL_Surface*)surface; 3793 sfc = (Render_Engine_GL_Surface*)surface;
3779 ns = (Evas_Native_Surface*)native_surface; 3794 ns = (Evas_Native_Surface*)native_surface;
3780 3795
@@ -3792,7 +3807,6 @@ eng_gl_native_surface_get(void *data EINA_UNUSED, void *surface, void *native_su
3792#endif 3807#endif
3793} 3808}
3794 3809
3795
3796static void * 3810static void *
3797eng_gl_api_get(void *data EINA_UNUSED, int version) 3811eng_gl_api_get(void *data EINA_UNUSED, int version)
3798{ 3812{
@@ -3800,8 +3814,7 @@ eng_gl_api_get(void *data EINA_UNUSED, int version)
3800 return NULL; 3814 return NULL;
3801 3815
3802#ifdef EVAS_GL 3816#ifdef EVAS_GL
3803 if (!_tls_init) 3817 if (!_check_gl()) return NULL;
3804 gl_lib_init();
3805 3818
3806 return &gl_funcs; 3819 return &gl_funcs;
3807#else 3820#else
@@ -4803,25 +4816,25 @@ static Evas_Func func =
4803 eng_font_text_props_info_create, 4816 eng_font_text_props_info_create,
4804 eng_font_right_inset_get, 4817 eng_font_right_inset_get,
4805 NULL, // No need to set output for software engine 4818 NULL, // No need to set output for software engine
4806 NULL, // need software mesa for gl rendering <- gl_surface_create 4819 eng_gl_surface_create, // need software mesa for gl rendering <- gl_surface_create
4807 NULL, // need software mesa for gl rendering <- gl_pbuffer_surface_create 4820 NULL, // need software mesa for gl rendering <- gl_pbuffer_surface_create
4808 NULL, // need software mesa for gl rendering <- gl_surface_destroy 4821 eng_gl_surface_destroy, // need software mesa for gl rendering <- gl_surface_destroy
4809 NULL, // need software mesa for gl rendering <- gl_context_create 4822 eng_gl_context_create, // need software mesa for gl rendering <- gl_context_create
4810 NULL, // need software mesa for gl rendering <- gl_context_destroy 4823 eng_gl_context_destroy, // need software mesa for gl rendering <- gl_context_destroy
4811 NULL, // need software mesa for gl rendering <- gl_make_current 4824 eng_gl_make_current, // need software mesa for gl rendering <- gl_make_current
4812 NULL, // need software mesa for gl rendering <- gl_string_query 4825 eng_gl_string_query, // need software mesa for gl rendering <- gl_string_query
4813 NULL, // need software mesa for gl rendering <- gl_proc_address_get 4826 eng_gl_proc_address_get, // need software mesa for gl rendering <- gl_proc_address_get
4814 NULL, // need software mesa for gl rendering <- gl_native_surface_get 4827 eng_gl_native_surface_get, // need software mesa for gl rendering <- gl_native_surface_get
4815 NULL, // need software mesa for gl rendering <- gl_api_get 4828 eng_gl_api_get, // need software mesa for gl rendering <- gl_api_get
4816 NULL, // need software mesa for gl rendering <- gl_direct_override 4829 NULL, // need software mesa for gl rendering <- gl_direct_override
4817 NULL, // need software mesa for gl rendering <- gl_get_pixels_set 4830 NULL, // need software mesa for gl rendering <- gl_get_pixels_set
4818 NULL, // need software mesa for gl rendering <- gl_surface_lock 4831 NULL, // need software mesa for gl rendering <- gl_surface_lock
4819 NULL, // need software mesa for gl rendering <- gl_surface_read_pixels 4832 NULL, // need software mesa for gl rendering <- gl_surface_read_pixels
4820 NULL, // need software mesa for gl rendering <- gl_surface_unlock 4833 NULL, // need software mesa for gl rendering <- gl_surface_unlock
4821 NULL, // need software mesa for gl rendering <- gl_error_get 4834 eng_gl_error_get, // need software mesa for gl rendering <- gl_error_get
4822 NULL, // need software mesa for gl rendering <- gl_current_context_get 4835 eng_gl_current_context_get, // need software mesa for gl rendering <- gl_current_context_get
4823 NULL, // need software mesa for gl rendering <- gl_current_surface_get 4836 eng_gl_current_surface_get, // need software mesa for gl rendering <- gl_current_surface_get
4824 NULL, // need software mesa for gl rendering <- gl_rotation_angle_get 4837 eng_gl_rotation_angle_get, // need software mesa for gl rendering <- gl_rotation_angle_get
4825 NULL, // need software mesa for gl rendering <- gl_surface_query 4838 NULL, // need software mesa for gl rendering <- gl_surface_query
4826 NULL, // need software mesa for gl rendering <- gl_surface_direct_renderable_get 4839 NULL, // need software mesa for gl rendering <- gl_surface_direct_renderable_get
4827 NULL, // need software mesa for gl rendering <- gl_image_direct_set 4840 NULL, // need software mesa for gl rendering <- gl_image_direct_set
@@ -5873,6 +5886,7 @@ gl_lib_init(void)
5873{ 5886{
5874#ifdef EVAS_GL 5887#ifdef EVAS_GL
5875 // Current ctx & sfc stuff 5888 // Current ctx & sfc stuff
5889 if (gl_lib_handle) return 1;
5876 if (!_tls_check()) return 0; 5890 if (!_tls_check()) return 0;
5877 5891
5878 // dlopen OSMesa 5892 // dlopen OSMesa
@@ -5888,23 +5902,33 @@ gl_lib_init(void)
5888 if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW); 5902 if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW);
5889 if (!gl_lib_handle) 5903 if (!gl_lib_handle)
5890 { 5904 {
5891 DBG("Unable to open libOSMesa: %s", dlerror()); 5905 WRN("Unable to open libOSMesa: %s", dlerror());
5906 DBG("Unable to support EvasGL in this engine module. Install OSMesa to get it running");
5892 return 0; 5907 return 0;
5893 } 5908 }
5894 5909
5895 //------------------------------------------------// 5910 //------------------------------------------------//
5896 if (!glue_sym_init()) return 0; 5911 if (!glue_sym_init())
5897 if (!gl_sym_init()) return 0; 5912 {
5913 WRN("Unable to glue OSMesa syms");
5914 return 0;
5915 }
5916 if (!gl_sym_init())
5917 {
5918 WRN("Unable to init OSMesa syms");
5919 return 0;
5920 }
5898 5921
5899 override_gl_apis(&gl_funcs); 5922 override_gl_apis(&gl_funcs);
5900 5923
5901 return 1; 5924 return 1;
5902#else 5925#else
5926 WRN("Evas GL not compiled in");
5903 return 0; 5927 return 0;
5904#endif 5928#endif
5905} 5929}
5906 5930
5907 5931/*
5908static void 5932static void
5909init_gl(void) 5933init_gl(void)
5910{ 5934{
@@ -5923,7 +5947,6 @@ init_gl(void)
5923 ORD(gl_string_query); // FIXME: Need to implement 5947 ORD(gl_string_query); // FIXME: Need to implement
5924 ORD(gl_proc_address_get); // FIXME: Need to implement 5948 ORD(gl_proc_address_get); // FIXME: Need to implement
5925 ORD(gl_native_surface_get); 5949 ORD(gl_native_surface_get);
5926 ORD(gl_api_get);
5927 ORD(gl_error_get); 5950 ORD(gl_error_get);
5928 ORD(gl_current_context_get); 5951 ORD(gl_current_context_get);
5929 ORD(gl_current_surface_get); 5952 ORD(gl_current_surface_get);
@@ -5931,7 +5954,7 @@ init_gl(void)
5931#undef ORD 5954#undef ORD
5932 } 5955 }
5933} 5956}
5934 5957*/
5935 5958
5936/* 5959/*
5937 ***** 5960 *****
@@ -5982,7 +6005,8 @@ module_open(Evas_Module *em)
5982 NULL, sizeof(Evas_Thread_Command_Ector_Surface), 128); 6005 NULL, sizeof(Evas_Thread_Command_Ector_Surface), 128);
5983 6006
5984 ector_init(); 6007 ector_init();
5985 init_gl(); 6008// do on demand when first evas_gl_api_get is called...
6009// init_gl();
5986 ector_glsym_set(dlsym, RTLD_DEFAULT); 6010 ector_glsym_set(dlsym, RTLD_DEFAULT);
5987 evas_common_pipe_init(); 6011 evas_common_pipe_init();
5988 6012