|
From: Enlightenment C. <no...@cv...> - 2006-10-22 10:04:32
|
Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_main.c e_start_main.c
Log Message:
speed up e17's login - reduce disk IO wait.
on my p4 3.4ghz + reiser3fs IO Wait time went from 2.6 to 1.9 seconds
(total login time went from 3.01511 to 2.29971, with 100% cached login time
being 0.41809)
on my core 2 duo laptop + ext3fs IO Wait time went from 2.05 to 1.15 seconds
(total login time went from 2.50988 to 1.60785, with 100% cached login time
being 0.45850)
this should speed up e's login a bit... i hope.
note - it is adaptive. it needs you to log in at least once using the current
code as it traps and logs certain file accesses and needs that log to replay
next login.
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_main.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -3 -r1.195 -r1.196
--- e_main.c 22 Oct 2006 02:14:08 -0000 1.195
+++ e_main.c 22 Oct 2006 10:03:58 -0000 1.196
@@ -3,6 +3,8 @@
*/
#include "e.h"
+EAPI int e_precache_end = 0;
+
/* local subsystem functions */
static void _e_main_shutdown_push(int (*func)(void));
static void _e_main_shutdown(int errorcode);
@@ -1404,6 +1406,7 @@
{
TS("SLEEP");
first_idle = 0;
+ e_precache_end = 1;
}
}
return 1;
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_start_main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- e_start_main.c 22 Oct 2006 06:07:12 -0000 1.5
+++ e_start_main.c 22 Oct 2006 10:03:58 -0000 1.6
@@ -3,6 +3,10 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/utsname.h>
+#include <fcntl.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
@@ -248,6 +252,72 @@
return 0;
}
+static void
+precache(void)
+{
+ FILE *f;
+ char *home;
+ char buf[4096], tbuf[256 * 1024];
+ struct stat st;
+ int l, fd, children = 0, cret;
+
+ home = getenv("HOME");
+ if (home)
+ snprintf(buf, sizeof(buf), "%s/.e-precache", home);
+ else
+ snprintf(buf, sizeof(buf), "/tmp/.e-precache");
+ f = fopen(buf, "r");
+ if (!f) return;
+ unlink(buf);
+ if (fork()) return;
+ while (fgets(buf, sizeof(buf), f));
+ rewind(f);
+ while (fgets(buf, sizeof(buf), f))
+ {
+ l = strlen(buf);
+ if (l > 0) buf[l - 1] = 0;
+ if (!fork())
+ {
+ if (buf[0] == 's')
+ {
+ stat(buf + 2, &st);
+ }
+ else if (buf[0] == 'o')
+ {
+ fd = open(buf + 2, O_RDONLY);
+ if (fd >= 0)
+ {
+ while (read(fd, tbuf, 256 * 1024) > 0);
+ close(fd);
+ }
+ }
+ else if (buf[0] == 'd')
+ {
+ fd = open(buf + 2, O_RDONLY);
+ if (fd >= 0)
+ {
+ while (read(fd, tbuf, 256 * 1024) > 0);
+ close(fd);
+ }
+ }
+ exit(0);
+ }
+ children++;
+ if (children > 400)
+ {
+ wait(&cret);
+ children--;
+ }
+ }
+ fclose(f);
+ while (children > 0)
+ {
+ wait(&cret);
+ children--;
+ }
+ exit(0);
+}
+
int
main(int argc, char **argv)
{
@@ -268,8 +338,10 @@
else snprintf(buf, sizeof(buf), "%s/lib", _prefix_path);
env_set("LD_LIBRARY_PATH", buf);
-// snprintf(buf, sizeof(buf), "%s/lib/enlightenment/preload/e_precache.so", _prefix_path);
-// env_set("LD_PRELOAD", buf);
+ snprintf(buf, sizeof(buf), "%s/lib/enlightenment/preload/e_precache.so", _prefix_path);
+ env_set("LD_PRELOAD", buf);
+
+ precache();
args = alloca((argc + 1) * sizeof(char *));
args[0] = "enlightenment";
|