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 2021/12/31 08:15:22 UTC

[GitHub] [incubator-doris] zuochunwei opened a new pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

zuochunwei opened a new pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558


   ## Proposed changes
   
   1. calc the total buf len before mallocing in the function _alloc_buf()
   2. delete unnecessary member data such as _long_text_buf
   3. use std::iota() to set std::vector<int> columns  consistently
   
   Close related #issue (replace it with issue number if it exists).
   
   Describe the overview of changes, and introduce why we need it.
   
   ## Types of changes
   
   What types of changes does your code introduce to Doris?
   _Put an `x` in the boxes that apply_
   
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] Documentation Update (if none of the other choices apply)
   - [ x] Code refactor (Modify the code structure, format the code, etc...)
   - [ ] Optimization. Including functional usability improvements and performance improvements.
   - [ ] Dependency. Such as changes related to third-party components.
   - [ ] Other.
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [ ] I have created an issue on (Fix #ISSUE) and described the bug/feature there in detail
   - [ ] Compiling and unit tests pass locally with my changes
   - [ ] I have added tests that prove my fix is effective or that my feature works
   - [ ] If these changes need document changes, I have updated the document
   - [ ] Any dependent changes have been merged
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 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] zuochunwei commented on a change in pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r779322688



##########
File path: be/src/olap/row_cursor.h
##########
@@ -36,10 +36,13 @@ class RowCursor {
 public:
     static const int DEFAULT_TEXT_LENGTH = 128;
 
-    RowCursor();
+    RowCursor() = default;
 
     // 遍历销毁field指针
-    ~RowCursor();
+    ~RowCursor() {
+        delete [] _owned_fixed_buf;
+        delete [] _variable_buf;

Review comment:
       no, because the type of _variable_buf is char*, so delete[] _variable_buf will just release the memory allocated by corresponding new[] not matter whatever the _variable_buf is used for.




-- 
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] wangbo commented on a change in pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
wangbo commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r779309215



##########
File path: be/src/olap/row_cursor.h
##########
@@ -36,10 +36,13 @@ class RowCursor {
 public:
     static const int DEFAULT_TEXT_LENGTH = 128;
 
-    RowCursor();
+    RowCursor() = default;
 
     // 遍历销毁field指针
-    ~RowCursor();
+    ~RowCursor() {
+        delete [] _owned_fixed_buf;
+        delete [] _variable_buf;

Review comment:
       If _variable_buf holds a ref of an Object such as Slice,can ```delete [] _variable_buf ``` trigger Slice's ?destructor.




-- 
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] wangbo commented on a change in pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
wangbo commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r779309215



##########
File path: be/src/olap/row_cursor.h
##########
@@ -36,10 +36,13 @@ class RowCursor {
 public:
     static const int DEFAULT_TEXT_LENGTH = 128;
 
-    RowCursor();
+    RowCursor() = default;
 
     // 遍历销毁field指针
-    ~RowCursor();
+    ~RowCursor() {
+        delete [] _owned_fixed_buf;
+        delete [] _variable_buf;

Review comment:
       If _variable_buf holds a ref of an Object such as Slice,can ```delete [] _variable_buf ``` trigger Slice's destructor.




-- 
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 #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r780189568



##########
File path: be/src/olap/row_cursor.cpp
##########
@@ -28,19 +28,6 @@ using std::string;
 using std::vector;
 
 namespace doris {
-RowCursor::RowCursor()
-        : _fixed_len(0), _variable_len(0), _string_field_count(0), _long_text_buf(nullptr) {}
-
-RowCursor::~RowCursor() {
-    delete[] _owned_fixed_buf;
-    delete[] _variable_buf;
-    if (_string_field_count > 0 && _long_text_buf != nullptr) {
-        for (int i = 0; i < _string_field_count; ++i) {
-            free(_long_text_buf[i]);

Review comment:
       i see, realloc in agg_update




-- 
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 edited a comment on pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei edited a comment on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1006446911


   > I have another question,Is using a continuous memory to store some strings `cpu-cache-friendly`? In current implementation, strings is kept in memory divided.
   
   reply the buf's size,  level1 cache size may 32/64k,this size may big enough


-- 
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 #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1007302968






-- 
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] HappenLee commented on a change in pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
HappenLee commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r780188135



##########
File path: be/src/olap/row_cursor.cpp
##########
@@ -28,19 +28,6 @@ using std::string;
 using std::vector;
 
 namespace doris {
-RowCursor::RowCursor()
-        : _fixed_len(0), _variable_len(0), _string_field_count(0), _long_text_buf(nullptr) {}
-
-RowCursor::~RowCursor() {
-    delete[] _owned_fixed_buf;
-    delete[] _variable_buf;
-    if (_string_field_count > 0 && _long_text_buf != nullptr) {
-        for (int i = 0; i < _string_field_count; ++i) {
-            free(_long_text_buf[i]);

Review comment:
       the long_text_buf should release one by one. because string type will realloc the mem 




-- 
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 closed pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei closed pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558


   


-- 
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] HappenLee commented on a change in pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
HappenLee commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r780188135



##########
File path: be/src/olap/row_cursor.cpp
##########
@@ -28,19 +28,6 @@ using std::string;
 using std::vector;
 
 namespace doris {
-RowCursor::RowCursor()
-        : _fixed_len(0), _variable_len(0), _string_field_count(0), _long_text_buf(nullptr) {}
-
-RowCursor::~RowCursor() {
-    delete[] _owned_fixed_buf;
-    delete[] _variable_buf;
-    if (_string_field_count > 0 && _long_text_buf != nullptr) {
-        for (int i = 0; i < _string_field_count; ++i) {
-            free(_long_text_buf[i]);

Review comment:
       the long_text_buf should release one by one. because string type will realloc the mem 




-- 
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 pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1007289882


   > I think there is another optimization point for `row_cursor`; When only `string type` is needed, it's clear that only `_long_text_buf` need to be allocated memory, `_variable_buf` won't be used, so in `_alloc_buf()`, allocation for _variable_buf is not necessary; I think the allocation for `_long_text_buf` and `_variable_buf` should be separated; Of course, this optimization can be done later. So I think `_long_text_buf` should not be removed;
   
   if all fields are long_text_buf, the _variable_len calculcted by init function will be 0, so memory will not allocated for var


-- 
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 pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1007283451






-- 
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 #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r779322688



##########
File path: be/src/olap/row_cursor.h
##########
@@ -36,10 +36,13 @@ class RowCursor {
 public:
     static const int DEFAULT_TEXT_LENGTH = 128;
 
-    RowCursor();
+    RowCursor() = default;
 
     // 遍历销毁field指针
-    ~RowCursor();
+    ~RowCursor() {
+        delete [] _owned_fixed_buf;
+        delete [] _variable_buf;

Review comment:
       no!
   
   because the type of _variable_buf is char*,  so delete[] _variable_buf will just release the memory allocated by corresponding new[]. not matter whatever the _variable_buf is used for.




-- 
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 pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1006446911


   > I have another question,Is using a continuous memory to store some strings `cpu-cache-friendly`? In current implementation, strings is kept in memory divided.
   
   reply the buf's size,  level1 cache size may 32/64k,this size may big enought 


-- 
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] wangbo commented on pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
wangbo commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1006443258


   I have another question,Is using a continuous memory to store some strings  ```cpu-cache-friendly```?
   In current implementation, strings is kept in memory divided.


-- 
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] wangbo commented on pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
wangbo commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1006436857


   I think there is another optimization point for ```row_cursor```;
   When only ```string type``` is needed,  it's clear that only ```_long_text_buf``` need to be allocated memory, ```_variable_buf``` won't be used, so in ```_alloc_buf()```, allocation for _variable_buf is not necessary;
   I think the allocation for ```_long_text_buf``` and ```_variable_buf``` should be separated;
   Of course, this optimization can be done later.
   So I think ```_long_text_buf``` should not be removed;


-- 
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 #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1007302968






-- 
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 #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r780189568



##########
File path: be/src/olap/row_cursor.cpp
##########
@@ -28,19 +28,6 @@ using std::string;
 using std::vector;
 
 namespace doris {
-RowCursor::RowCursor()
-        : _fixed_len(0), _variable_len(0), _string_field_count(0), _long_text_buf(nullptr) {}
-
-RowCursor::~RowCursor() {
-    delete[] _owned_fixed_buf;
-    delete[] _variable_buf;
-    if (_string_field_count > 0 && _long_text_buf != nullptr) {
-        for (int i = 0; i < _string_field_count; ++i) {
-            free(_long_text_buf[i]);

Review comment:
       i see, realloc in agg_update




-- 
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 #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on a change in pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#discussion_r779437852



##########
File path: be/src/olap/row_cursor.h
##########
@@ -36,10 +36,13 @@ class RowCursor {
 public:
     static const int DEFAULT_TEXT_LENGTH = 128;
 
-    RowCursor();
+    RowCursor() = default;
 
     // 遍历销毁field指针
-    ~RowCursor();
+    ~RowCursor() {
+        delete [] _owned_fixed_buf;
+        delete [] _variable_buf;

Review comment:
       i have appended comments to explain why i do this




-- 
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 pull request #7558: [refactor](olap) prefer to malloc for _variable_buf once rather than malloc repeatedly

Posted by GitBox <gi...@apache.org>.
zuochunwei commented on pull request #7558:
URL: https://github.com/apache/incubator-doris/pull/7558#issuecomment-1007283451


   > 
   
   i got your meaning


-- 
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