From owner-freebsd-ports@FreeBSD.ORG Sun Mar 1 10:11:52 2009 Return-Path: Delivered-To: freebsd-ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3AEFF106566B for ; Sun, 1 Mar 2009 10:11:52 +0000 (UTC) (envelope-from lioux@FreeBSD.org) Received: from goat.gigo.com (ipv6.gigo.com [IPv6:2001:470:1:18::2]) by mx1.freebsd.org (Postfix) with ESMTP id 1F8778FC0C for ; Sun, 1 Mar 2009 10:11:52 +0000 (UTC) (envelope-from lioux@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by goat.gigo.com (Postfix) with ESMTP id 17CA66F94 for ; Sun, 1 Mar 2009 02:11:52 -0800 (PST) Received: from goat.gigo.com ([127.0.0.1]) by localhost (vette.gigo.com [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id z6reWbkuI88X for ; Sun, 1 Mar 2009 02:11:51 -0800 (PST) Received: from 189.74.32.106 (201-88-36-118.bsace702.dsl.brasiltelecom.net.br [201.88.36.118]) by goat.gigo.com (Postfix) with ESMTPA id 6E3CD6D00 for ; Sun, 1 Mar 2009 02:11:51 -0800 (PST) Received: (qmail 40861 invoked by uid 1001); 1 Mar 2009 07:11:18 -0300 Message-ID: <20090301101118.40843.qmail@exxodus.fedaykin.here> Date: Sun, 1 Mar 2009 07:11:18 -0259 From: Mario Sergio Fujikawa Ferreira To: freebsd-ports@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Cc: stas@FreeBSD.org Subject: Testers for lang/ruby19 with Profile-Guided Optimization X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Mar 2009 10:11:52 -0000 --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, After the work on lang/ruby18, I did some work on lang/ruby19 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 test); 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. What is different from the previous lang/ruby19 patch? Well, the test cases have some timing problems when ran profiling instrumentation so we do not generate as much profiling information with this one; i.e., it is not as optimized as it could be because some tests fail during profiling. However, we are safe since the tests work after we re-build without the instrumentation. I am not a ruby expert so I would like input on this one: 1) Does it perform better than ruby19 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/ruby19-pgo-2009030100.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 --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch --- Makefile.orig 2009-03-01 07:05:01.000000000 -0300 +++ Makefile 2009-03-01 07:05:18.000000000 -0300 @@ -42,7 +42,8 @@ NO_LATEST_LINK= yes -OPTIONS= RDOC "Build and install Rdoc indexes" off \ +OPTIONS= PGO "Enable Profile-Guided Optimization" off \ + RDOC "Build and install Rdoc indexes" off \ DEBUG "Compile-in debug info" off .include @@ -75,8 +76,14 @@ CONFIGURE_ARGS+= --disable-install-doc .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 @@ -133,6 +140,13 @@ ${MV} ${BUILD_WRKSRC}/ext/${d} ${WRKDIR}/ .endfor +.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 @@ -288,4 +302,54 @@ test: @(cd ${WRKSRC}; ${MAKE} test) +validate:: + @(cd ${WRKSRC}; ${MAKE} update-rubyspec) + @(cd ${WRKSRC}; ${MAKE} test-rubyspec) + +.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: +# Check everything to generate profiling information. +# Everything run so slowly that thread tests break on timing issues +# so we will have to "trust" it just works during the build phase. +# Manually test after build to make sure. + @-(cd ${BUILD_WRKSRC}; ${MAKE} test) +# @-(cd ${BUILD_WRKSRC}; ${MAKE} test-all) + +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 --HlL+5n6rz5pIUxbD--