Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 36FB6200C60 for ; Mon, 24 Apr 2017 15:46:11 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3581D160BB2; Mon, 24 Apr 2017 13:46:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7D574160B99 for ; Mon, 24 Apr 2017 15:46:10 +0200 (CEST) Received: (qmail 22442 invoked by uid 500); 24 Apr 2017 13:46:09 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 22423 invoked by uid 99); 24 Apr 2017 13:46:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Apr 2017 13:46:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id D41F8CFF3C for ; Mon, 24 Apr 2017 13:46:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.497 X-Spam-Level: X-Spam-Status: No, score=-3.497 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-2.796, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id twtzJ0Nw-Sdd for ; Mon, 24 Apr 2017 13:46:06 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 25D0A5F5F8 for ; Mon, 24 Apr 2017 13:46:06 +0000 (UTC) Received: from [192.168.1.121] ([195.141.68.118]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MCcvy-1ctKvO2hxy-009NH4 for ; Mon, 24 Apr 2017 15:46:04 +0200 Subject: Re: Towards a better compiler To: dev@groovy.apache.org References: <58FA6544.2040806@gmx.org> <58FCD328.7050105@gmx.org> From: Jochen Theodorou Message-ID: <243cf8fa-e2d7-60e9-0cd6-005d7a406baa@gmx.org> Date: Mon, 24 Apr 2017 15:46:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:nGsR2DaLNCGq8KnPqUdJfPQXghFQtrAGSAhA6292jFZ2Ok6jRke FLMkUGhE8ofchFN5HmIsn7wY7egDBROa/G1jw0J133yEvdkPEnWuTQZPdHfIsmiyv4VxBOd Jy9AUL6W+pLYeBet4GYbvNJZKN1DybgHSJQbdGhNkxR++ZnUgLYHQWmbjRT6+TCdcqpyMUY 0u1Y2izesJoi10/shS+3A== X-UI-Out-Filterresults: notjunk:1;V01:K0:cMLUFWEm/Dw=:cBYzLF7jM2NZRBPDs1z9Ib lwVvjQXvB2fqA7c48zn4Jv5yh5kCxk4NpsGDIYgv2mW599t1sk6l4nYVIsm2elx89dzrbpPY0 fNMUtp7OAKlJXRkOB3k41ou/+2B56u3kHfr10t9r2kWNT1l12PoAuqSeh18yhZFB+UAiNdHUn ksjGfdwu7F+w9rVKEP6B9F1zxx2UlYdS7rPSNhYuUvEfVr8f8ow35JKGxXRMuEnMQQBgqFgsg WGExXxgmITRwgKDNFekNjoR9oNqJ2q3FN2U7OCfBwbnafJ60laENsYCz1wH8mYN6KHsBj8Ix4 Ok7dObI9ObmnSjMC5C6N1P3pgLGb8dJCTRl8gg1Y+rpvANTL14DpTj2se23pO+gaUzatxz34G 5WWBDNWGcq/mAHUNNs+s4jw6zSCjjhgg0cJNrPKu9kiXJG8lL0nAn04y9wBkgAmKktddnoTqg J6j0qskxH8VPeH6KTxXRHQZ6MtWANA5cDJ47aJhOx+jOErSY9T+rGmj2/8wIy8dJwtDSKFk0+ 7La72+6YsUTNc9ZSmtAjm/oCZMYKW8UgI1RW1QLZSHjCow787wfBtXc/yrMOXACQP8sE/1fLs cCtSjGqKXlOBv3Rc3I+0cR3XP4PHrIKmhvLmoJI33lZbAK890rxWFljpm6KN1pjM7h3lzETX/ 4zwrm/yDys3rfRUXv5jRcjHXpFNiuvZks9PCwFKoM0GfBp2rn14xbcbQscfMpB+byoMO3JYSm h2HwYIRxe8bIJHAVm8lVdqAEb6wWZyq/odDrS9HS3a6QT73jmtj5eM20W7VwAOtBr0C2AsrTV nnEyN8u archived-at: Mon, 24 Apr 2017 13:46:11 -0000 On 24.04.2017 10:56, Cédric Champeau wrote: > > > Implementing equals/hashcode does not give you any order in a Set or > Map you can rely on. Really, I still don´t get what you target with > that. You require them in set to avoid duplicates. > > > I'm not talking about order here. I'm talking about reproducibility. A > linked hash set guarantees that things are read in the order they were > inserted. This is in general just enough. For example, we read in the > bytecode a list of interfaces, we add them to a set. If it's not linked, > then when we read them back, you have no guarantee. It has nothing to do > with _sorting_, which would reorder interfaces typically. The 2 uses > cases are different. So we agree it is the "linked" ability that gives the order and equals and hashcode are secondary > then don´t. Let´s change the API to not return Set. > > Yes. I would say +100 if it wasn't for performance. Typically if the > algorithm needs to use `contains`, a `Set` is way more efficient. I was saying to use List, because there is no equals and hashcode defined. If they are not defined your search will be invalid unless, you are searching using the exact same instance. And... what hashcode function do you suggest for MethodNode and ClassNode? Because I think they won't be cheap. If they are too expensive "way more efficient" will become very different for small sets. > And > that's exactly why we use sets in lots of places. So to be clear, I did > a quick review of where we used sets and maps, and replaced that with > linked hash set and linked hash map when we needed both to guarantee > that the order of insertion is preserved (not an absolute order) *and* > that the algorithm required fast checks. This is all we need, I think. > But I'm calling for more than just a quick review, we should recheck all > our usage precisely. And avoid binary breaking changes, of course :) as I said, maps are probably different, since there we most probably do not use the AST instances as key, and if we did, it is probably a bug. For the set cases.... well, maybe it would be better to give the container better search abilities instead of exposing a special collection here. That way we can ensure we have the implementation we need. bye Jochen