You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org> on 2017/12/07 19:48:08 UTC

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Bikramjeet Vig has uploaded this change for review. ( http://gerrit.cloudera.org:8080/8541


Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method body is truncated) before the llvm module is finalized.

Testing:
Tested manually by executing the following query and inspecting
the dump of the optimized llvm module.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
4 files changed, 50 insertions(+), 24 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/8
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 8
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Michael Ho (Code Review)" <ge...@cloudera.org>.
Michael Ho has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 13:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/8541/13/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/13/be/src/codegen/llvm-codegen.cc@898
PS13, Line 898: ReplaceCallSites
> should i add a dcheck for here to check if the replacement function is fina
Sounds like a good idea.

However, this is also making the assumption that 'new_fn' is a handcrafted IR function which seems to be case for all callers now. May want to verify that either 'new_fn' is not a handcrafted IR function or that it is finalized already.



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 13
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 22 Dec 2017 20:26:55 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#15).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method is deleted from the module) before the llvm module is finalized.

Testing:
- added a backend test to exercise the added code path.
- tested manually by executing the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo';
and looking at the logs to verify that 'InsertRuntimeFilters' and
'FilterContextInsert' methods have been removed.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
M be/src/exprs/scalar-fn-call.cc
5 files changed, 104 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/15
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 15
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 13:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/8541/13/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/13/be/src/codegen/llvm-codegen.cc@898
PS13, Line 898: ReplaceCallSites
should i add a dcheck for here to check if the replacement function is finalized?
This would prevent us from running into a situation where impala would crash if the replacement function is not finalized and gets removed before finalizing the module.



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 13
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 22 Dec 2017 19:32:08 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 14:

(2 comments)

all core tests working with this patch and llvm 5.
carrying over Michael's +2

http://gerrit.cloudera.org:8080/#/c/8541/13/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/13/be/src/codegen/llvm-codegen.cc@898
PS13, Line 898: ReplaceCallSites
> Sounds like a good idea.
Done


http://gerrit.cloudera.org:8080/#/c/8541/14/be/src/exprs/scalar-fn-call.cc
File be/src/exprs/scalar-fn-call.cc:

http://gerrit.cloudera.org:8080/#/c/8541/14/be/src/exprs/scalar-fn-call.cc@441
PS14, Line 441: ir_fn = codegen->FinalizeFunction(ir_fn);
fixed this case found during testing, where the function was being added without being finalized



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 14
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 29 Dec 2017 20:57:04 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#11).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method is deleted from the module) before the llvm module is finalized.

Testing:
- added a backend test to exercise the added code path.
- tested manually by executing the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo';
and looking at the logs to verify that 'InsertRuntimeFilters' and
'FilterContextInsert' methods have been removed.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
4 files changed, 98 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/11
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 11
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Michael Ho (Code Review)" <ge...@cloudera.org>.
Michael Ho has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 8:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@167
PS8, Line 167: }
> Yes, that's a legitimate use case. Can you please add a test case in which 
Sorry, typo. I meant to say that is _not_ a legitimate use case.

A legitimate use case is to bail in the middle of a codegen function _without_ referencing the hand-crafted IR function and _without_ finalizing the hand-crafted IR.



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 8
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 15 Dec 2017 01:39:33 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 13: Code-Review+2

(2 comments)

Carrying over Michael's +2
will run core tests on local with LLVM 5 before running GVO on this.

http://gerrit.cloudera.org:8080/#/c/8541/12/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/12/be/src/codegen/llvm-codegen.cc@859
PS12, Line 859: nullptr, n
> nullptr, nullptr
Done


http://gerrit.cloudera.org:8080/#/c/8541/12/be/src/codegen/llvm-codegen.cc@1082
PS12, Line 1082: fn->eraseFromParent();
> Feel free to ignore but do you think it will be sufficient to just print th
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 13
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Wed, 20 Dec 2017 20:17:16 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Michael Ho (Code Review)" <ge...@cloudera.org>.
Michael Ho has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 12: Code-Review+2

(2 comments)

http://gerrit.cloudera.org:8080/#/c/8541/12/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/12/be/src/codegen/llvm-codegen.cc@859
PS12, Line 859: NULL, NULL
nullptr, nullptr


http://gerrit.cloudera.org:8080/#/c/8541/12/be/src/codegen/llvm-codegen.cc@1082
PS12, Line 1082: fn->print(stream, nullptr, false, true);
Feel free to ignore but do you think it will be sufficient to just print the function name ? I am a bit worried about potential log spew if we print the function body when we run queries with types (e.g. char) which we will always not codegen for.



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 12
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 19 Dec 2017 21:58:46 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Tim Armstrong (Code Review)" <ge...@cloudera.org>.
Tim Armstrong has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 9: Code-Review+1

(1 comment)

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@167
PS8, Line 167: }
> that would crash llvm(and hence the process) during FinalizeModule
We could use the magic IMPALA_ASSERT_DEBUG_DEATH() macro if we want to test that code path. It might not be worth testing if it's an invalid use of the API.



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 9
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Wed, 13 Dec 2017 00:01:24 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#10).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method body is truncated) before the llvm module is finalized.

Tested manually as follows:
- move the cleanup instructions before the instructions for printing
the unoptimized llvm module in LlvmCodeGen::FinalizeModule()
- run the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo'
- inspect the dump of the unoptimized module and make sure the methods
'InsertRuntimeFilters' and 'FilterContextInsert' are not defined

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
4 files changed, 58 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/10
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 10
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method is deleted from the module) before the llvm module is finalized.

Testing:
- added a backend test to exercise the added code path.
- tested manually by executing the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo';
and looking at the logs to verify that 'InsertRuntimeFilters' and
'FilterContextInsert' methods have been removed.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Reviewed-on: http://gerrit.cloudera.org:8080/8541
Reviewed-by: Bikramjeet Vig <bi...@cloudera.com>
Tested-by: Impala Public Jenkins
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
M be/src/exprs/scalar-fn-call.cc
5 files changed, 104 insertions(+), 35 deletions(-)

Approvals:
  Bikramjeet Vig: Looks good to me, approved
  Impala Public Jenkins: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 16
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Michael Ho (Code Review)" <ge...@cloudera.org>.
Michael Ho has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 11:

(7 comments)

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@111
PS11, Line 111:     for(auto fn : codegen->handcrafted_functions_){
              :       if(fn == function) return true;
              :     }
              :     return false;
const auto& hf = codegen->handcrafted_functions_;
return find(hf.begin(), hf.end(), function) != hf.end();


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@498
PS11, Line 498: NULL
nullptr


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@506
PS11, Line 506: NULL
nullptr


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@507
PS11, Line 507: NULL
nullptr


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.h
File be/src/codegen/llvm-codegen.h:

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.h@228
PS11, Line 228: NULL
nullptr


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.h@228
PS11, Line 228: NULL
nullptr


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.cc@182
PS11, Line 182:  NULL
nullptr



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 11
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 19 Dec 2017 20:42:49 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 10:

(7 comments)

http://gerrit.cloudera.org:8080/#/c/8541/10//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/8541/10//COMMIT_MSG@12
PS10, Line 12: (method body is truncated)
> deleted from module ?
Done


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.h
File be/src/codegen/llvm-codegen.h:

http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.h@374
PS10, Line 374: removed
> deleted from the module
Done


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.h@374
PS10, Line 374: their function body
> the functions
Done


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@658
PS10, Line 658: DCHECK(
> nit: DCHECK_EQ()
Done


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@771
PS10, Line 771: codegen_->handcrafted_functions_.push_back(fn);
> Mind adding a comment on why we only add function to "handcrafted_functions
Done


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@1059
PS10, Line 1059: deleting the function's body.
> Is this still true ?
Done


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@1062
PS10, Line 1062:       fn->eraseFromParent();
> I assume this should not happen very often so is it worth logging to aid de
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 10
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 19 Dec 2017 00:54:58 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 15: Code-Review+2

fixed clang tidy error.
Carrying over Michael's +2


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 15
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Sat, 30 Dec 2017 01:53:55 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Michael Ho (Code Review)" <ge...@cloudera.org>.
Michael Ho has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 8:

(10 comments)

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@167
PS8, Line 167: }
Can you please also add a test case in which we don't finalize a handcrafted IR but still use it to replace some call sites in a loaded cross-compiled function ? Not sure if we can recover from this kind of error ? May be it'll crash the test.


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@327
PS8, Line 327:   EXPECT_TRUE(VerifyFunction(codegen.get(), string_test_fn));
Does this become unnecessary given you called FinalizeFunction() in CodegenStringTest() ?


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@330
PS8, Line 330:   void* jitted_fn = NULL;
             :   AddFunctionToJit(codegen.get(), string_test_fn, &jitted_fn);
Same here.


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h
File be/src/codegen/llvm-codegen.h:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@107
PS8, Line 107: build
nit: built


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@109
PS8, Line 109: Loaded
Cross-compiled


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@219
PS8, Line 219: should
must

And if FinalizeFunction() is not called on a handcrafted-IR function, it will be deleted during FinalizeModule(), right ? Would be great to mention it somewhere.


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@363
PS8, Line 363:   /// FinalizeFunction() on the returned function as it is already materialized.
I find this last statement potentially confusing. Most of the time, we call CloneFunction() or GetFunction() to get a copy of the cross-compiled function as template to be customized for a query. And that means we still need to call FinalizeFunction() on the customized function. FinalizeFunction() shouldn't have anything to do with bitcode materialization, right ?


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@385
PS8, Line 385:   /// this method.
Shouldn't there be a DCHECK in this function to enforce this ?


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@765
PS8, Line 765: generated 
generated from scratch


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.cc@1062
PS8, Line 1062: deleteBody()
Why not fn->eraseFromParent() ?

In theory, if there is a bug in some codegen function and we didn't finalize a handcrafted IR but still use it to replace some call sites in a loaded cross-compiled function, things may still work if just delete the function body but that may generate wrong result, right ? If we remove the unfinalized IR function altogether from the module, the compilation should fail, right ?



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 8
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Thu, 07 Dec 2017 23:28:18 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 11:

(7 comments)

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@111
PS11, Line 111:     for(auto fn : codegen->handcrafted_functions_){
              :       if(fn == function) return true;
              :     }
              :     return false;
> const auto& hf = codegen->handcrafted_functions_;
Done


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@498
PS11, Line 498: NULL
> nullptr
Done


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@506
PS11, Line 506: NULL
> nullptr
Done


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen-test.cc@507
PS11, Line 507: NULL
> nullptr
Done


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.h
File be/src/codegen/llvm-codegen.h:

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.h@228
PS11, Line 228: NULL
> nullptr
Done


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.h@228
PS11, Line 228: NULL
> nullptr
Done


http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/11/be/src/codegen/llvm-codegen.cc@182
PS11, Line 182:  NULL
> nullptr
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 11
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 19 Dec 2017 21:44:37 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 14: Code-Review+2

carrying over Michael's +2


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 14
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 29 Dec 2017 20:57:27 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Tim Armstrong (Code Review)" <ge...@cloudera.org>.
Tim Armstrong has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 10: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 10
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Thu, 14 Dec 2017 22:38:44 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Bikramjeet Vig has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 8:

(10 comments)

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@167
PS8, Line 167: }
> Can you please also add a test case in which we don't finalize a handcrafte
that would crash llvm(and hence the process) during FinalizeModule


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@327
PS8, Line 327:   EXPECT_TRUE(VerifyFunction(codegen.get(), string_test_fn));
> Does this become unnecessary given you called FinalizeFunction() in Codegen
yes, removed


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@330
PS8, Line 330:   void* jitted_fn = NULL;
             :   AddFunctionToJit(codegen.get(), string_test_fn, &jitted_fn);
> Same here.
This is necessary as we need to explicitly add it to the list of JIT functions as FinalizeFunction does not do that


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h
File be/src/codegen/llvm-codegen.h:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@107
PS8, Line 107: build
> nit: built
Done


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@109
PS8, Line 109: Loaded
> Cross-compiled
Done


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@219
PS8, Line 219: should
> must
Done


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@363
PS8, Line 363:   /// FinalizeFunction() on the returned function as it is already materialized.
> I find this last statement potentially confusing. Most of the time, we call
Done


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@385
PS8, Line 385:   /// this method.
> Shouldn't there be a DCHECK in this function to enforce this ?
Done


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.h@765
PS8, Line 765: generated 
> generated from scratch
Done


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen.cc@1062
PS8, Line 1062: deleteBody()
> Why not fn->eraseFromParent() ?
switching to fn->eraseFromParent().

If we remove the unfinalized IR function altogether from the module but still use it to replace some call sites in a loaded cross-compiled function, the compilation would crash impalad.

I dont currently see anywhere in the codebase where we would use a handcrafted IR even if finalize function fails. So, switching to fn->eraseFromParent() would work. Also, I ll run core tests again with this patch using llvm 5 after I get a +2 but before I run the GVO merge job.



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 8
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 12 Dec 2017 23:55:43 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#13).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method is deleted from the module) before the llvm module is finalized.

Testing:
- added a backend test to exercise the added code path.
- tested manually by executing the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo';
and looking at the logs to verify that 'InsertRuntimeFilters' and
'FilterContextInsert' methods have been removed.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
4 files changed, 99 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/13
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 13
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 14:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/1657/


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 14
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 29 Dec 2017 20:58:15 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 15:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/1659/


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 15
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Sat, 30 Dec 2017 01:54:16 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#14).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method is deleted from the module) before the llvm module is finalized.

Testing:
- added a backend test to exercise the added code path.
- tested manually by executing the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo';
and looking at the logs to verify that 'InsertRuntimeFilters' and
'FilterContextInsert' methods have been removed.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
M be/src/exprs/scalar-fn-call.cc
5 files changed, 104 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/14
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 14
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#9).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method body is truncated) before the llvm module is finalized.

Testing:
Tested manually by executing the following query and inspecting
the dump of the optimized llvm module.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
4 files changed, 58 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/9
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 9
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Bikramjeet Vig (Code Review)" <ge...@cloudera.org>.
Hello Michael Ho, Tim Armstrong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/8541

to look at the new patch set (#12).

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................

IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Currently, if an error is encountered during the creation of a
handcrafted codegen method, then the resulting IR is left in an
incomplete state. This patch ensures that all such IRs are cleaned up
(method is deleted from the module) before the llvm module is finalized.

Testing:
- added a backend test to exercise the added code path.
- tested manually by executing the following query:
select * from charTable A, charTable B
where A.charColumn = B.charColumn and A.charColumn = 'foo';
and looking at the logs to verify that 'InsertRuntimeFilters' and
'FilterContextInsert' methods have been removed.

Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
---
M be/src/codegen/llvm-codegen-test.cc
M be/src/codegen/llvm-codegen.cc
M be/src/codegen/llvm-codegen.h
M be/src/exec/hdfs-text-scanner.cc
4 files changed, 99 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/41/8541/12
-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 12
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 15: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 15
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Sat, 30 Dec 2017 05:31:37 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 14: Verified-1

Build failed: https://jenkins.impala.io/job/gerrit-verify-dryrun/1657/


-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 14
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Sat, 30 Dec 2017 00:34:24 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module

Posted by "Michael Ho (Code Review)" <ge...@cloudera.org>.
Michael Ho has posted comments on this change. ( http://gerrit.cloudera.org:8080/8541 )

Change subject: IMPALA-6177: Cleanup incomplete handcrafted IRs before finalizing module
......................................................................


Patch Set 10:

(8 comments)

Looking good. Just some more minor comments. Please add a test case and I can +2 it afterwards.

http://gerrit.cloudera.org:8080/#/c/8541/10//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/8541/10//COMMIT_MSG@12
PS10, Line 12: (method body is truncated)
deleted from module ?


http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc
File be/src/codegen/llvm-codegen-test.cc:

http://gerrit.cloudera.org:8080/#/c/8541/8/be/src/codegen/llvm-codegen-test.cc@167
PS8, Line 167: }
> We could use the magic IMPALA_ASSERT_DEBUG_DEATH() macro if we want to test
Yes, that's a legitimate use case. Can you please add a test case in which we don't call FinalizeFunction() but don't reference it either. This is to exercise the path which deletes functions which aren't finalized.


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.h
File be/src/codegen/llvm-codegen.h:

http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.h@374
PS10, Line 374: removed
deleted from the module


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.h@374
PS10, Line 374: their function body
the functions


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc
File be/src/codegen/llvm-codegen.cc:

http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@658
PS10, Line 658: DCHECK(
nit: DCHECK_EQ()


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@771
PS10, Line 771: codegen_->handcrafted_functions_.push_back(fn);
Mind adding a comment on why we only add function to "handcrafted_functions_" only when builder != NULL ? It's probably related to the fact that we don't insert the basic block "entry" if we builder == nullptr ?


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@1059
PS10, Line 1059: deleting the function's body.
Is this still true ?


http://gerrit.cloudera.org:8080/#/c/8541/10/be/src/codegen/llvm-codegen.cc@1062
PS10, Line 1062:       fn->eraseFromParent();
I assume this should not happen very often so is it worth logging to aid debugging ?

It's a bit unfortunate that we cannot add DCHECK(fn->user_empty()) here as the module hasn't been materialized yet. Please consider adding a comment stating that any reference to this function will lead to crash in LLVM (and thus Impala).



-- 
To view, visit http://gerrit.cloudera.org:8080/8541
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If975cfb3906482b36dd6ede32ca81de6fcee1d7f
Gerrit-Change-Number: 8541
Gerrit-PatchSet: 10
Gerrit-Owner: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Bikramjeet Vig <bi...@cloudera.com>
Gerrit-Reviewer: Michael Ho <kw...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Fri, 15 Dec 2017 01:11:54 +0000
Gerrit-HasComments: Yes