You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/02/16 08:40:11 UTC
[GitHub] [incubator-doris] zuochunwei opened a new pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
zuochunwei opened a new pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090
# Proposed changes
1. use union + bitfield C++ language features to reuse the memory, reduce the size of RowRefList from 32 to 16 bytes
2. ssb test indicate(Q4.1): benefit from RowRefList size reduce, hash table's memory consuming is greatly decreased, almost 40%
3. refactor RowRefList iterate logic, i think it becomes more simple after modifing
4. run performance, change is little, i need more time to test for it
Issue Number: close #xxx
## Problem Summary:
Describe the overview of changes.
## Checklist(Required)
1. Does it affect the original behavior: (Yes/No/I Don't know)
2. Has unit tests been added: (Yes/No/No Need)
3. Has document been added or modified: (Yes/No/No Need)
4. Does it need to update dependencies: (Yes/No)
5. Are there any changes that cannot be rolled back: (Yes/No)
## Further comments
If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] spaces-X commented on a change in pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
spaces-X commented on a change in pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#discussion_r808661055
##########
File path: be/src/vec/exec/join/vhash_join_node.cpp
##########
@@ -317,10 +319,10 @@ struct ProcessHashTableProbe {
for (auto it = mapped.begin(); it.ok(); ++it) {
++current_offset;
for (size_t j = 0; j < right_col_len; ++j) {
- auto& column = *it->block->get_by_position(j).column;
+ auto& column = *it->block()->get_by_position(j).column;
mcol[j + right_col_idx]->insert_from(column, it->row_num);
}
- visited_map.emplace_back(&it->visited);
+ visited_map.emplace_back(&(*it));
Review comment:
why not just `emplace_back(it)`?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] zuochunwei commented on a change in pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#discussion_r808628352
##########
File path: be/src/vec/exec/join/vhash_join_node.cpp
##########
@@ -286,9 +286,12 @@ struct ProcessHashTableProbe {
// use in right join to change visited state after
// exec the vother join conjunt
- std::vector<bool*> visited_map;
+ std::vector<void*> visited_map;
visited_map.reserve(1.2 * _batch_size);
+#define visited_map_or(index, value) do { if (value) ((RowRef*)visited_map[index])->visited = 1; } while (0)
Review comment:
got, i will change as you say
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] zuochunwei commented on a change in pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#discussion_r808627987
##########
File path: be/src/vec/exec/join/join_op.h
##########
@@ -22,19 +22,42 @@
#include "vec/core/block.h"
namespace doris::vectorized {
+
/// Reference to the row in block.
struct RowRef {
using SizeT = uint32_t; /// Do not use size_t cause of memory economy
- const Block* block = nullptr;
- SizeT row_num = 0;
- // Use in right join to mark row is visited
- // TODO: opt the varaible to use it only need
- bool visited = false;
+ // using union to represent two cases
+ // 1. when RowRefList containing only one RowRef, visited + blockptr are valid
+ // 2. when RowRefList contaning multi RowRef, it's used through next pointer
+ union {
+ struct {
+ uint64_t visited : 1;
Review comment:
i need 64bit wide to union with void*
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] zuochunwei commented on a change in pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#discussion_r808677199
##########
File path: be/src/vec/exec/join/vhash_join_node.cpp
##########
@@ -317,10 +319,10 @@ struct ProcessHashTableProbe {
for (auto it = mapped.begin(); it.ok(); ++it) {
++current_offset;
for (size_t j = 0; j < right_col_len; ++j) {
- auto& column = *it->block->get_by_position(j).column;
+ auto& column = *it->block()->get_by_position(j).column;
mcol[j + right_col_idx]->insert_from(column, it->row_num);
}
- visited_map.emplace_back(&it->visited);
+ visited_map.emplace_back(&(*it));
Review comment:
&(*it) is not same to it, this is because ForwardIterator has overloaded the operator*
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] github-actions[bot] commented on pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#issuecomment-1042595887
PR approved by anyone and no changes requested.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] BiteTheDDDDt commented on a change in pull request #8090: (Vectorized)(Optimization) refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
BiteTheDDDDt commented on a change in pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#discussion_r807805187
##########
File path: be/src/vec/exec/join/join_op.h
##########
@@ -22,19 +22,42 @@
#include "vec/core/block.h"
namespace doris::vectorized {
+
/// Reference to the row in block.
struct RowRef {
using SizeT = uint32_t; /// Do not use size_t cause of memory economy
- const Block* block = nullptr;
- SizeT row_num = 0;
- // Use in right join to mark row is visited
- // TODO: opt the varaible to use it only need
- bool visited = false;
+ // using union to represent two cases
+ // 1. when RowRefList containing only one RowRef, visited + blockptr are valid
+ // 2. when RowRefList contaning multi RowRef, it's used through next pointer
+ union {
+ struct {
+ uint64_t visited : 1;
Review comment:
Why is it defined as uint64 here, not use automatic memory alignment?
##########
File path: be/src/vec/exec/join/vhash_join_node.cpp
##########
@@ -286,9 +286,12 @@ struct ProcessHashTableProbe {
// use in right join to change visited state after
// exec the vother join conjunt
- std::vector<bool*> visited_map;
+ std::vector<void*> visited_map;
visited_map.reserve(1.2 * _batch_size);
+#define visited_map_or(index, value) do { if (value) ((RowRef*)visited_map[index])->visited = 1; } while (0)
Review comment:
The macros in our code style need uppercase
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [incubator-doris] morningman commented on pull request #8090: [refactor](optimize)refactor RowRef/RowRefList to decrease hash table memory size
Posted by GitBox <gi...@apache.org>.
morningman commented on pull request #8090:
URL: https://github.com/apache/incubator-doris/pull/8090#issuecomment-1055340501
hi @zuochunwei , sorry for the later reply. Please rebase the code to solve the conflict.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org