You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2021/01/14 06:33:03 UTC
[GitHub] [zookeeper] lanicc opened a new pull request #1578: ZOOKEEPER-4057: NIOServerCnxnFactory.selectorThreads,using List instead of HashSet
lanicc opened a new pull request #1578:
URL: https://github.com/apache/zookeeper/pull/1578
Using List costs less memory and computing than HashSet.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [zookeeper] lanicc commented on pull request #1578: ZOOKEEPER-4057: NIOServerCnxnFactory.selectorThreads,using List instead of HashSet
Posted by GitBox <gi...@apache.org>.
lanicc commented on pull request #1578:
URL: https://github.com/apache/zookeeper/pull/1578#issuecomment-769516110
@maoling
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [zookeeper] lanicc commented on pull request #1578: ZOOKEEPER-4057: NIOServerCnxnFactory.selectorThreads,using List instead of HashSet
Posted by GitBox <gi...@apache.org>.
lanicc commented on pull request #1578:
URL: https://github.com/apache/zookeeper/pull/1578#issuecomment-768125661
simple test:
`public static void main(String[] args) {
int numObj = 1;
Set<Object> set = new HashSet<>();
for (int i = 0; i < numObj; i++) {
set.add(new Object());
}
System.out.println("Size of HashSet: " + GraphLayout.parseInstance(set).totalSize());
List<Object> list = new ArrayList<>();
for (int i = 0; i < numObj; i++) {
list.add(new Object());
}
System.out.println("Size of ArrayList: " + GraphLayout.parseInstance(list).totalSize());
long start, end;
Iterator<Object> setIterator = set.iterator();
start = System.nanoTime();
while (setIterator.hasNext()) {
setIterator.next();
}
end = System.nanoTime();
System.out.println("HashSet iterator cost: " + (end - start));
Iterator<Object> listIterator = list.iterator();
start = System.nanoTime();
while (listIterator.hasNext()) {
listIterator.next();
}
end = System.nanoTime();
System.out.println("ArrayList iterator cost: " + (end - start));
}`
result:
_Size of HashSet: 256
Size of ArrayList: 112
HashSet iterator cost: 20474
ArrayList iterator cost: 460_
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [zookeeper] maoling commented on pull request #1578: ZOOKEEPER-4057: NIOServerCnxnFactory.selectorThreads,using List instead of HashSet
Posted by GitBox <gi...@apache.org>.
maoling commented on pull request #1578:
URL: https://github.com/apache/zookeeper/pull/1578#issuecomment-765355980
@lanicc
> Using List costs less memory and computing than HashSet.
Could you please give us more explanations for this? Any benchmark report?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org