Date: Sun, 15 Jul 2007 23:40:49 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 123556 for review Message-ID: <200707152340.l6FNensC072498@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123556 Change 123556 by gcooper@optimus-revised_pkgtools on 2007/07/15 23:40:00 -Section off simple profiler helper code in preparation for comparing vanilla pkg_install vs modified execution times and stats. -Delete old perform.c. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/add/perform.c#5 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#6 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/lib.h#5 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/pen.c#5 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/plist.c#11 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/version/perform.old.c#3 delete Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/add/perform.c#5 (text+ko) ==== @@ -137,7 +137,7 @@ } Home = make_playpen(playpen, sb.st_size * 4); -#if SIMPLE_PROF_TRY +#if SIMPLE_PROF static struct timespec before, after, time_diff; #endif @@ -145,7 +145,7 @@ errx(1, "unable to make playpen for %lld bytes", (long long)sb.st_size * 4); where_to = Home; -#if SIMPLE_PROF_TRY +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &before); #endif @@ -153,13 +153,13 @@ if (!getenv("_TOP")) setenv("_TOP", Home, 1); -#if SIMPLE_PROF_TRY +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &after); time_diff.tv_nsec = after.tv_nsec - before.tv_nsec; time_diff.tv_sec = after.tv_sec - before.tv_sec; - printf( "(%s) Difference: %3.20lf secs\n", "_TOP setenv", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); + fprintf(stderr, "(%s) Difference: %3.20lf secs\n", "_TOP setenv", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); #endif if (unpack(pkg_fullname, extract)) { @@ -169,7 +169,7 @@ goto bomb; } -#if SIMPLE_PROF_TRY +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &before); #endif @@ -181,13 +181,13 @@ goto bomb; } -#if SIMPLE_PROF_TRY +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &after); time_diff.tv_nsec = after.tv_nsec - before.tv_nsec; time_diff.tv_sec = after.tv_sec - before.tv_sec; - printf( "(%s) Difference: %3.20lf secs\n", "+CONTENTS fopen", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); + fprintf(stderr, "(%s) Difference: %3.20lf secs\n", "+CONTENTS fopen", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); #endif read_plist(&Plist, cfile); ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#6 (text+ko) ==== @@ -296,9 +296,11 @@ { char cmd[FILENAME_MAX]; +#if SIMPLE_PROF static struct timespec before, after, time_diff; clock_gettime(CLOCK_REALTIME, &before); +#endif if (fname[0] == '/') snprintf(cmd, FILENAME_MAX, "/bin/cp -r %s %s", fname, to); @@ -309,6 +311,7 @@ errx(2, "%s: could not perform '%s'", __func__, cmd); } +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &after); time_diff.tv_nsec = after.tv_nsec - before.tv_nsec; @@ -316,6 +319,7 @@ time_diff.tv_sec = after.tv_sec - before.tv_sec; fprintf(stderr, "(%s) Difference: %3.20lf secs\n", "copy_file", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); +#endif } @@ -324,9 +328,11 @@ { char cmd[FILENAME_MAX]; +#if SIMPLE_PROF static struct timespec before, after, time_diff; clock_gettime(CLOCK_REALTIME, &before); +#endif if (fname[0] == '/') snprintf(cmd, FILENAME_MAX, "/bin/mv %s %s", fname, to); @@ -337,6 +343,7 @@ errx(2, "%s: could not perform '%s'", __func__, cmd); } +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &after); time_diff.tv_nsec = after.tv_nsec - before.tv_nsec; @@ -344,6 +351,7 @@ time_diff.tv_sec = after.tv_sec - before.tv_sec; fprintf(stderr, "(%s) Difference: %3.20lf secs\n", "move_file", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); +#endif } @@ -399,9 +407,11 @@ unpack(const char *pkg, const char *flist) { +#if SIMPLE_PROF static struct timespec before, after, time_diff; clock_gettime(CLOCK_REALTIME, &before); +#endif const char *comp, *cp; char suff[80]; @@ -429,6 +439,7 @@ ret_code = 1; } +#if SIMPLE_PROF clock_gettime(CLOCK_REALTIME, &after); time_diff.tv_nsec = after.tv_nsec - before.tv_nsec; @@ -436,6 +447,7 @@ time_diff.tv_sec = after.tv_sec - before.tv_sec; printf( "(%s) Difference: %3.20lf secs\n", "unpack", (double) ( time_diff.tv_sec + time_diff.tv_nsec/1e9 ) ); +#endif return ret_code; ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/lib.h#5 (text+ko) ==== @@ -52,6 +52,10 @@ #define YES 2 #define NO 1 +#ifndef SIMPLE_PROF +#define SIMPLE_PROF 0 +#endif + /* Usually "rm", but often "echo" during debugging! */ #define REMOVE_CMD "/bin/rm" @@ -161,11 +165,13 @@ off_t min_free(const char *); //static char *find_playpen(char *, off_t); +#if SIMPLE_PROF char *make_playpen_np(char *, off_t); void leave_playpen_np(void); char *find_playpen_np(char *, off_t); char* run_generic_playpen_prof(char *fn_name, ...); +#endif /* String */ char *get_dash_string(char **); @@ -198,7 +204,9 @@ int unpack(const char *, const char *); void format_cmd(char *, int, const char *, const char *, const char *); +#if SIMPLE_PROF int delete_hierarchy_np(const char *, Boolean, Boolean); +#endif /* Msg */ void upchuck(const char *); @@ -224,7 +232,9 @@ int delete_package(Boolean, Boolean, Package *); Boolean make_preserve_name(char *, int, const char *, const char *); +#if SIMPLE_PROF int run_generic_plist_prof(char *fn_name, ...); + void add_plist_np(Package *, plist_t, const char *); void add_plist_top_np(Package *, plist_t, const char *); void delete_plist_np(Package *pkg, Boolean all, plist_t type, const char *name); @@ -234,6 +244,8 @@ int delete_package_np(Boolean, Boolean, Package *); void read_plist_np(Package *, FILE *); +#endif + int trim_end_whitespace(char *); /* For all */ @@ -244,7 +256,7 @@ char **matchinstalled(match_t, char **, int *); char **matchbyorigin(const char *, int *); int isinstalledpkg(const char *name); -int pattern_match(match_t MatchType, char *pattern, const char *pkgname); +int pattern_match(match_t MatchType, const char *pattern, const char *pkgname); /* Dependencies */ int sortdeps(char **); ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/pen.c#5 (text+ko) ==== @@ -32,6 +32,7 @@ static char PenLocation[FILENAME_MAX]; static char Previous[FILENAME_MAX]; +#if SIMPLE_PROF char * run_generic_playpen_prof(char *fn_name, ...) { @@ -77,6 +78,7 @@ return ret_string; } +#endif char * where_playpen(void) @@ -84,14 +86,20 @@ return PenLocation; } +#if SIMPLE_PROF static char * find_playpen(char *pen, off_t sz) { return run_generic_playpen_prof("find_playpen", pen, sz); } +#endif /* Find a good place to play. */ char * +#if SIMPLE_PROF find_playpen_np(char *pen, off_t sz) +#else +find_playpen(char *pen, off_t sz) +#endif { char *cp; struct stat sb; @@ -141,19 +149,25 @@ strcpy(pen, pstack[pdepth]); free(pstack[pdepth--]); } - + +#if SIMPLE_PROF char * make_playpen(char *pen, off_t sz) { return run_generic_playpen_prof("make_playpen", pen, sz); } +#endif /* * Make a temporary directory to play in and chdir() to it, returning * pathname of previous working directory. */ char * +#if SIMPLE_PROF make_playpen_np(char *pen, off_t sz) +#else +make_playpen(char *pen, off_t sz) +#endif { if (!find_playpen(pen, sz)) return NULL; @@ -196,15 +210,21 @@ return Previous; } +#if SIMPLE_PROF void leave_playpen() { run_generic_playpen_prof("leave_playpen"); } +#endif /* Convenience routine for getting out of playpen */ void +#if SIMPLE_PROF leave_playpen_np() +#else +leave_playpen() +#endif { void (*oldsig)(int); ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/plist.c#11 (text+ko) ==== @@ -28,6 +28,7 @@ #include <stdarg.h> #include <sys/time.h> +#if SIMPLE_PROF int run_generic_plist_prof(char *fn_name, ...) { @@ -119,9 +120,14 @@ { run_generic_plist_prof("add_plist", p, type, arg); } +#endif void +#if SIMPLE_PROF add_plist_np(Package *p, plist_t type, const char *arg) +#else +add_plist(Package *p, plist_t type, const char *arg) +#endif { PackingList tmp; @@ -151,14 +157,20 @@ } +#if SIMPLE_PROF void add_plist_top(Package *p, plist_t type, const char *arg) { run_generic_plist_prof("add_plist_top", p, type, arg); } +#endif void +#if SIMPLE_PROF add_plist_top_np(Package *p, plist_t type, const char *arg) +#else +add_plist_top(Package *p, plist_t type, const char *arg) +#endif { PackingList tmp; @@ -277,18 +289,25 @@ pkg->head = pkg->tail = NULL; } +#if SIMPLE_PROF int plist_cmd(const char *s, char **arg) { return run_generic_plist_prof("plist_cmd", s, arg); } +#endif /* * For an ascii string denoting a plist command, return its code and * optionally its argument(s) */ + int +#if SIMPLE_PROF plist_cmd_np(const char *s, char **arg) +#else +plist_cmd(const char *s, char **arg) +#endif { char cmd[FILENAME_MAX + 20]; /* 20 == fudge for max cmd len */ char *cp; @@ -440,14 +459,20 @@ } +#if SIMPLE_PROF void read_plist(Package *pkg, FILE *fp) { run_generic_plist_prof("read_plist", pkg, fp); } +#endif void +#if SIMPLE_PROF read_plist_np(Package *pkg, FILE *fp) +#else +read_plist(Package *pkg, FILE *fp) +#endif { char *plines; @@ -558,15 +583,21 @@ return len; } +#if SIMPLE_PROF void write_plist(Package *pkg, FILE *fp) { run_generic_plist_prof("write_plist", pkg, fp); } +#endif /* Write a packing list to a file, converting commands to ascii equivs */ void +#if SIMPLE_PROF write_plist_np(Package *pkg, FILE *fp) +#else +write_plist(Package *pkg, FILE *fp) +#endif { PackingList plist = pkg->head; @@ -663,11 +694,13 @@ } } +#if SIMPLE_PROF int delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) { return run_generic_plist_prof("delete_package", ign_err, nukedirs, pkg); } +#endif /* * Delete the results of a package installation. @@ -676,7 +709,11 @@ * run it too in cases of failure. */ int +#if SIMPLE_PROF delete_package_np(Boolean ign_err, Boolean nukedirs, Package *pkg) +#else +delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) +#endif { PackingList p; const char *Where = ".", *last_file = ""; @@ -816,15 +853,21 @@ #define REMOVE(file,ie) (remove(file) && !(ie)) #endif +#if SIMPLE_PROF int delete_hierarchy(const char *dir, Boolean ign_err, Boolean nukedirs) { return run_generic_plist_prof("delete_hierarchy", dir, ign_err, nukedirs); } +#endif /* Selectively delete a hierarchy */ int +#if SIMPLE_PROF delete_hierarchy_np(const char *dir, Boolean ign_err, Boolean nukedirs) +#else +delete_hierarchy(const char *dir, Boolean ign_err, Boolean nukedirs) +#endif { char *cp1, *cp2;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707152340.l6FNensC072498>
