Date: Sat, 28 Feb 2009 12:36:06 -0259 From: Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org> To: freebsd-ports@FreeBSD.org Subject: Testers for lang/ruby18 with Profile-Guided Optimization Message-ID: <20090228153606.77414.qmail@exxodus.fedaykin.here>
next in thread | raw e-mail | index | archive | help
--nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I did some work on the lang/ruby18 to enable Profile-Guided Optimization (PGO) build support. What I did? (Steps 1-4 handled by pgo port target). ------- RECIPE 1) Compile everything with CFLAGS/LDFLAGS containing '-fprofile-generate'; 2) Run lots of test cases to generate profiling information (make check); 3) Remove all binaries leaving only the profiling information behind; 4) Replace all instances of '-fprofile-generate' with '-fprofile-use'; 5) Re-compile everything using the profiling information. ------- If I did it correctly, you should not notice any differences on port usage aside from PGO option and a huge build compilation time. Please, verify if you can that I did all steps of the "RECIPE" correctly. I am not a ruby expert so I would like input on this one: 1) Does it perform better than ruby18 compiled without PGO? Hard number benchmarks welcome. Check http://github.com/acangiano/ruby-benchmark-suite/tree/master 2) Also, could others run specification conformance verification checks on the resulting ruby interpreter? So that we have multiple cross verification. Perhaps, with rubyspec? I hope you find this useful and that it performs as expected. I want to go after lang/ruby19. Perhaps, even python and perl5. The modified port file can be found at http://people.freebsd.org/~lioux/ruby18-pgo-2009022800.tbz but the patch is so small that I have it as an attachment. Regards, -- Mario S F Ferreira - DF - Brazil - "I guess this is a signature." feature, n: a documented bug | bug, n: an undocumented feature --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch --- Makefile.orig 2009-02-12 15:54:27.000000000 -0200 +++ Makefile 2009-02-28 09:04:05.000000000 -0300 @@ -38,6 +38,7 @@ ONIGURUMA "Build with oniguruma regular expressions lib" off \ GCPATCH "Build with GC performance statistics collector" off \ IPV6 "Enable IPv6 support" on \ + PGO "Enable Profile-Guided Optimization" off \ RDOC "Build and install Rdoc indexes" off \ DEBUG "Compile-in debug info" off @@ -57,6 +58,10 @@ CFLAGS+= ${PTHREAD_CFLAGS} # Keep this, else ruby will fail to load LDFLAGS+= ${PTHREAD_LIBS} # libraries dependent op libpthread. +.if defined(WITH_PGO) +PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+pgo +.endif + .if defined(WITH_PTHREADS) CONFIGURE_ARGS+=--enable-pthread PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+pthreads @@ -98,8 +103,14 @@ CONFIGURE_ARGS+= --enable-ipv6 .endif +.if defined(WITH_PGO) +CONFIGURE_ENV= CFLAGS="${CFLAGS} -fprofile-generate" \ + LDFLAGS="-fprofile-generate" \ + LIBS="${LDFLAGS}" +.else CONFIGURE_ENV= CFLAGS="${CFLAGS}" \ LIBS="${LDFLAGS}" +.endif .if ${RUBY_VER} == ${RUBY_DEFAULT_VER} MLINKS= ${RUBY_NAME}.1 ruby.1 @@ -170,6 +181,13 @@ cd ${WRKSRC}/ && ${PATCH} -p0 < ${PATCHDIR}/extrapatch-oniguruma-reggnu.c .endif +.if defined(WITH_PGO) +.if target(pre-build) +.error Makefile error since pre-build target has already been defined +.endif +pre-build: pgo +.endif + post-build: # # Hack to allow modules to be installed into separate PREFIX and/or under user @@ -321,4 +339,47 @@ (cd ${WRKSRC}/rubyspec && git clone git://github.com/rubyspec/mspec.git) (cd ${WRKSRC}/rubyspec/rubyspec && env PATH=${WRKSRC}/rubyspec/mspec/bin:${PATH} mspec -t ${PREFIX}/bin/ruby${RUBY_SUFFIX}) +.if defined(WITH_PGO) +pgo: pgo-pre-build pgo-build pgo-run pgo-post-run pgo-clean + +pgo-pre-build: + @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \ + ${REINPLACE_CMD} -E \ + -e 's,^(((C|LD)FLAGS|LDSHARED|ldflags)[[:space:]]*=.*)-fprofile-generate,\1,' \ + -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \ + -e 's,^(((C|LD)FLAGS|LDSHARED|ldflags)[[:space:]]*=.*)$$,\1 -fprofile-generate,' \ + {} \; + +# XXX +# Can I use do-build directly instead of copying its contents? +# I mean, if I do +# +# pgo-build: do-build +# +# Will do-build still be called when bsd.port.mk gets to the build target? +# Or, will it have "already" been executed by the pgo-build target? +# +pgo-build: + @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${ALL_TARGET}) + +pgo-run: test +# Check everything to generate profiling information. +# We will ignore any errors if test target works + @-(cd ${BUILD_WRKSRC}; ${MAKE} check) + +pgo-post-run: + @${FIND} ${BUILD_WRKSRC} -type f -name Makefile -exec \ + ${REINPLACE_CMD} -E \ + -e 's,^(((C|LD)FLAGS|LDSHARED|ldflags)[[:space:]]*=.*)-fprofile-generate,\1,' \ + -e 's,^(CFLAGS[[:space:]]*=.*)-fprofile-use,\1,' \ + -e 's,^(CFLAGS[[:space:]]*=.*)$$,\1 -fprofile-use,' \ + {} \; + @${REINPLACE_CMD} -E \ + -e 's,-fprofile-generate,-fprofile-use,g' \ + ${CONFIGURE_WRKSRC}/config.status + +pgo-clean: + @(cd ${BUILD_WRKSRC}; ${MAKE} clean) +.endif # if defined(WITH_PGO) + .include <bsd.port.post.mk> --nFreZHaLTZJo0R7j--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090228153606.77414.qmail>