From owner-freebsd-ports@FreeBSD.ORG Sat Feb 28 15:37:24 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 CABD8106568D for ; Sat, 28 Feb 2009 15:37:24 +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 A998E8FC0A for ; Sat, 28 Feb 2009 15:37:24 +0000 (UTC) (envelope-from lioux@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by goat.gigo.com (Postfix) with ESMTP id 2322F6DFA for ; Sat, 28 Feb 2009 07:37:24 -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 2t6kG-QmIjq7 for ; Sat, 28 Feb 2009 07:37:23 -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 345E76D0E for ; Sat, 28 Feb 2009 07:37:22 -0800 (PST) Received: (qmail 77423 invoked by uid 1001); 28 Feb 2009 12:36:06 -0300 Message-ID: <20090228153606.77414.qmail@exxodus.fedaykin.here> Date: Sat, 28 Feb 2009 12:36:06 -0259 From: Mario Sergio Fujikawa Ferreira To: freebsd-ports@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Cc: Subject: Testers for lang/ruby18 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: Sat, 28 Feb 2009 15:37:25 -0000 --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 --nFreZHaLTZJo0R7j--