From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id EE9E01960251 for ; Thu, 16 Jul 2015 16:16:06 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 14CDDB5D8D1 for ; Thu, 16 Jul 2015 16:44:51 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 0298797A827 for ; Thu, 16 Jul 2015 16:44:53 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YR9qGTE29s3b for ; Thu, 16 Jul 2015 16:44:52 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 832AC97A820 for ; Thu, 16 Jul 2015 16:44:52 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 6842A952447 for ; Thu, 16 Jul 2015 16:44:50 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8C685120485; Thu, 16 Jul 2015 16:44:49 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id D1C2412045D for ; Thu, 16 Jul 2015 16:44:46 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=m4dVcdzhwYsGsVgIuhPNK8JcaQM=; b=TRHueKceGtD2ps+ar/ G6bcIK4jPvArlBS/WzXPnmpCvkLl6uaf+BmntqxXHgW+Qi8PVfkFayDS6cm0yumO KjMSXs95SpPjWPMHajHFS3KqbMR+JDVjDU0CzozUdMa+pjXiNzCbYLC2fs7uHTcs r4M5nAokZgyvtbh9+N5WIprw8= Received: by filter0651p1mdw1.sendgrid.net with SMTP id filter0651p1mdw1.11677.55A760E817 2015-07-16 07:44:42.303784723 +0000 UTC Received: from herokuapp.com (ec2-54-161-165-249.compute-1.amazonaws.com [54.161.165.249]) by ismtpd-006 (SG) with ESMTP id 14e95d293b0.2ae2.243d1 Thu, 16 Jul 2015 07:44:42 +0000 (UTC) Date: Thu, 16 Jul 2015 07:44:42 +0000 From: nobu@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44615 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10902 X-Redmine-Issue-Author: tmm1 X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6csMZ60QWRrCpBs0mp3C+KrMpBmHuJBHMnp8 +1n6iCsMbrOhjHxNAw8cGinYCksFH6l56HJA669RmdD0dCZAtOHAI9xv+kZM48nDIGeGgLn+HLAC/1 s1RH5Fl7BS2NP56IjfDL4KqYF2ks2DUOl4Ne X-SendGrid-Contentd-ID: {"test_id":"1437032683"} X-ML-Name: ruby-core X-Mail-Count: 69997 Subject: [ruby-core:69997] [Ruby trunk - Bug #10902] require("enumerator") scans LOAD_PATH 2x on every invocation X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10902 has been updated by Nobuyoshi Nakada. It will disallow a library named "enumerator.rb". ---------------------------------------- Bug #10902: require("enumerator") scans LOAD_PATH 2x on every invocation https://bugs.ruby-lang.org/issues/10902#change-53433 * Author: Aman Gupta * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.1.5 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- On every invocation of `require "enumerator"` (for example during boot when many gems require it), the VM will scan the load path twice: once for enumerator.rb and again for enumerator.so. Of course, no file is found because enumerator is now shipped within the VM by default. ~~~ $ ruby -e' p $LOADED_FEATURES[0] ' "enumerator.so" $ ruby -e' p $LOAD_PATH.size ' 8 $ strace -e trace=open ruby -e' 1.times{ require "enumerator" } ' 2>&1 | grep enumerator.rb | wc -l 8 $ strace -e trace=open ruby -e' 1.times{ require "enumerator" } ' 2>&1 | grep enumerator.so | wc -l 8 $ strace -e trace=open ruby -e' 10.times{ require "enumerator" } ' 2>&1 | grep enumerator.so | wc -l 80 $ strace -e trace=open ruby -e' 100.times{ require "enumerator" } ' 2>&1 | grep enumerator.so | wc -l 800 ~~~ In enumerator.c, we call `rb_provide("enumerator.so")` which adds it to $LOADED_FEATURES. This means `require "enumerator.so"` can be optimized, but most libraries do not include the .so extension when requiring enumerator. -- https://bugs.ruby-lang.org/