You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by HuangWHWHW <gi...@git.apache.org> on 2015/08/17 05:32:47 UTC

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

GitHub user HuangWHWHW opened a pull request:

    https://github.com/apache/flink/pull/1029

    [FLINK-2534][RUNTIME]Improve in CompactingHashTable.java

    1. Remove the var currentForwardPointer is unused in the code since this can reduce little memory cost.
    2.Take the numInSegment++ out of the if branch and remove the else branch to decrease the loop complexity.
    3.Improve the "while" to a formula:
    numBuckets += numPartitions - numBuckets % numPartitions;
    
    Otherwise, I found some places just simply using "for" to find a max or min number like the code following:
    'private int getMaxPartition() {
    		int maxPartition = 0;
    		for(InMemoryPartition<T> p1 : this.partitions) {
    			if(p1.getBlockCount() > maxPartition) {
    				maxPartition = p1.getBlockCount();
    			}
    		}
    		return maxPartition;
    	}'
    This does some harm to the performance.
    Should we use some algorithm(.i.e RMQ, Segment tree, Heap structure) to take a optimization?


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HuangWHWHW/flink FLINK-2534

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/1029.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1029
    
----
commit 4303d6541cd539715d64780b1c4dc2b883ead99e
Author: HuangWHWHW <40...@qq.com>
Date:   2015-08-17T03:31:02Z

    [FLINK-2534][RUNTIME]Improve in CompactingHashTable.java

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by StephanEwen <gi...@git.apache.org>.
Github user StephanEwen commented on the pull request:

    https://github.com/apache/flink/pull/1029#issuecomment-131759047
  
    This seems correct, will merge this...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1029#discussion_r37166847
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/CompactingHashTable.java ---
    @@ -223,7 +223,7 @@ public CompactingHashTable(TypeSerializer<T> buildSideSerializer,
     		// check the size of the first buffer and record it. all further buffers must have the same size.
     		// the size must also be a power of 2
     		this.segmentSize = memorySegments.get(0).size();
    -		if ( (this.segmentSize & this.segmentSize - 1) != 0) {
    +		if ((this.segmentSize & this.segmentSize - 1) != 0) {
    --- End diff --
    
    please avoid tiny formatting changes, they just clutter up the diff.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by HuangWHWHW <gi...@git.apache.org>.
Github user HuangWHWHW commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1029#discussion_r37168080
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/CompactingHashTable.java ---
    @@ -223,7 +223,7 @@ public CompactingHashTable(TypeSerializer<T> buildSideSerializer,
     		// check the size of the first buffer and record it. all further buffers must have the same size.
     		// the size must also be a power of 2
     		this.segmentSize = memorySegments.get(0).size();
    -		if ( (this.segmentSize & this.segmentSize - 1) != 0) {
    +		if ((this.segmentSize & this.segmentSize - 1) != 0) {
    --- End diff --
    
    Sorry, this maybe a mistake that pressed a space.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1029#discussion_r37166816
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/CompactingHashTable.java ---
    @@ -406,9 +403,7 @@ public void insertOrReplaceRecord(T record) throws IOException {
     						return;
     					}
     				}
    -				else {
    -					numInSegment++;
    -				}
    +				numInSegment++;
    --- End diff --
    
    this is not equivalent to the old implementation, since numInSegent is no longer incremented if "this.buildSideComparator.equalToReference(valueAtPosition)" is true, since we return.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by sachingoel0101 <gi...@git.apache.org>.
Github user sachingoel0101 commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1029#discussion_r37167529
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/CompactingHashTable.java ---
    @@ -406,9 +403,7 @@ public void insertOrReplaceRecord(T record) throws IOException {
     						return;
     					}
     				}
    -				else {
    -					numInSegment++;
    -				}
    +				numInSegment++;
    --- End diff --
    
    It's a local variable, so this doesn't matter.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by HuangWHWHW <gi...@git.apache.org>.
Github user HuangWHWHW commented on the pull request:

    https://github.com/apache/flink/pull/1029#issuecomment-131692903
  
    Sorry for careless.
    Take a little change.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1029#discussion_r37167787
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/operators/hash/CompactingHashTable.java ---
    @@ -406,9 +403,7 @@ public void insertOrReplaceRecord(T record) throws IOException {
     						return;
     					}
     				}
    -				else {
    -					numInSegment++;
    -				}
    +				numInSegment++;
    --- End diff --
    
    Ah, nevermind then.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2534][RUNTIME]Improve in CompactingHash...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/1029


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---