Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Arrow-related code to incorporate IPC code improvements since 0.4.x, simplifications and perf improvements #65

Merged
merged 1 commit into from Sep 8, 2017

Conversation

wesm
Copy link
Contributor

@wesm wesm commented Sep 3, 2017

  • Use up-to-date Arrow IPC serialization / read APIs
  • Use vector appends with Arrow builders (cf ARROW-1468)
  • Avoid extra full result set memory copy in multithreaded fetches
  • Use library calls for pretty printing (cf ARROW-1396)

@CLAassistant
Copy link

CLAassistant commented Sep 3, 2017

CLA assistant check
All committers have signed the CLA.

@asuhan
Copy link
Contributor

asuhan commented Sep 3, 2017

Thanks, the API simplifications look very nice. Regarding exceptions, it all depends on their nature. If it's running out of memory for example, you can throw OutOfMemory defined in DataMgr/BufferMgr/BufferMgr.h.

@wesm
Copy link
Contributor Author

wesm commented Sep 3, 2017

OK, I'll add a function to create different exception types based on the type of error status

Copy link
Contributor Author

@wesm wesm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About all for tonight -- I need to do some do some debugging to get the test suite passing again. The next step beyond this is to make a bridge between MapD's CudaMgr and Arrow's GPU memory management so that the IPC code can write into device memory owned by MapD in a clean way: https://issues.apache.org/jira/browse/ARROW-1423.

Once I finish all this some additional testing from folks would be helpful to ensure I haven't broken anything, or instructions how I can test

As a last matter (probably in a follow up patch), I'm going to add some simple APIs for dealing with SysV and POSIX shared memory segments: https://issues.apache.org/jira/browse/ARROW-1385

@@ -68,36 +69,36 @@ std::vector<TargetValue> ArrowResultSet::getNextRow(const bool translate_strings
const auto& column_typeinfo = getColType(i);
switch (column_typeinfo.get_type()) {
case kSMALLINT: {
CHECK(dynamic_cast<const arrow::NumericArray<arrow::Int16Type>*>(&column));
const auto& i16_column = static_cast<const arrow::NumericArray<arrow::Int16Type>&>(column);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not recommend using arrow::NumericArray -- use the typedefs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I didn't notice them when I wrote this.

CHECK(is_valid.get());
ARROW_THROW_NOT_OK(typed_builder->Append(vals.data(), length, *is_valid));
} else {
ARROW_THROW_NOT_OK(typed_builder->Append(vals.data(), length));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vector appends

@asuhan
Copy link
Contributor

asuhan commented Sep 6, 2017

@wesm Thanks, I'll have a look tomorrow. For testing, have a look at https://github.com/mapd/mapd-core/blob/master/run_sanity_tests. You can run it as is, but you only need to run ExecuteTest (keep the first 9 lines unchanged).

@wesm
Copy link
Contributor Author

wesm commented Sep 6, 2017

Yep, I found that. I'll step around gdb and fix the bugs I introduced, probably tomorrow later in the day

#define ARROW_THROW_NOT_OK(s) \
do { \
::arrow::Status _s = (s); \
if (ARROW_PREDICT_FALSE(!_s.ok())) { \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you can use UNLIKELY from Shared/likely.h. I guess everyone has a version of this macro somewhere in the codebase.

@asuhan
Copy link
Contributor

asuhan commented Sep 7, 2017

Do the tests pass now?

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

Not yet, I am going to look at them hopefully before I go to bed tonight

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

I think it would be best to defer improvements re: direct writes to GPU device memory (i.e. https://github.com/apache/arrow/blob/master/cpp/src/arrow/gpu/cuda_arrow_ipc.h#L50) to a subsequent patch.

I also will need to update the toolchain files with an updated Arrow version and build recipe. 0.7.0 will probably be released next week roughly so you shouldn't have to be on an unreleased version for very long

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

I'm out of gas for tonight. I have a few free hours tomorrow morning (Eastern Time) so I'll look at this first thing and and get the issues worked out

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

@asuhan I'm finding when I build with gcc 4.9 that I get errors like

3: Test command: /home/wesm/code/mapd-core/build/Tests/ExecuteTest "--gtest_output=xml:../"
3: Test timeout computed to be: 9.99988e+06
3: F0907 11:00:11.645380 18703 QueryRunner.cpp:36] Check failed: boost::filesystem::exists(base_path) 
3: *** Check failure stack trace: ***
3:     @     0x7f45a03e2d5e  google::LogMessage::Fail()
3:     @     0x7f45a03e2caa  google::LogMessage::SendToLog()
3:     @     0x7f45a03e2690  google::LogMessage::Flush()
3:     @     0x7f45a03e5597  google::LogMessageFatal::~LogMessageFatal()
3:     @          0x120f8b6  get_session()
3:     @          0x11dadb3  main
3:     @     0x7f459c89ff45  __libc_start_main
3:     @          0x1174d9c  (unknown)
3:     @              (nil)  (unknown)

When I build with clang-3.8 instead, the tests work, but gdb doesn't work very well -- I'm able to get break points to work but inspecting variables seems not to work. I don't have any issues with gdb elsewhere, so it seems this is something MapD-specific. I can debug with print statements but gdb would really be better

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

I created a tmp symlink to the data directory in Tests and seem to be in business. I must have followed the directions wrong someplace but let me know for the future

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

Looking at this again later this evening

@asuhan
Copy link
Contributor

asuhan commented Sep 7, 2017

OK, I'll have a look myself tomorrow if you don't get to the bottom of it. FYI, I've seen a similar type of crash during my initial development of the test and it was due to buffer ownership problems. Holding the PoolBuffers fixed it.

@wesm
Copy link
Contributor Author

wesm commented Sep 7, 2017

Hm, interesting. Perhaps a pointer is being leaked somewhere. I will let you know if I can't sort it out

As an aside, it would also be better to use std::shared_ptr<RecordBatch>. That type is only copyable by accident. Just opened https://issues.apache.org/jira/browse/ARROW-1486

@wesm
Copy link
Contributor Author

wesm commented Sep 8, 2017

OK, tests are passing again. I summarized the work in the commit message.

Some follow up JIRAs

When you use BufferReader with the IPC read functions, so do not need to manually retain a reference to the original buffer, because internally the buffers in the record batch have a reference to the parent. See https://github.com/apache/arrow/blob/master/cpp/src/arrow/io/memory.cc#L227. If you had to keep track of which arrow::Buffer owns the memory all the time it would be complete madness. If you ever run into any problems with chained memory references, please bug me as I've tried to be really careful about simple zero-copy and RAII-based memory management but no one is perfect =) Better to fix the underlying issues than work around them.

…to 0.7.x

* Avoid extra full result set memory copy in multithreaded fetches
* Use vector appends with Arrow builders (cf ARROW-1468)
* Use up-to-date Arrow IPC serialization / read APIs
* Fix memory ownership issues with RecordBatch::column (returns a new object
  now)
* Use library calls for pretty printing (cf ARROW-1396)
@wesm
Copy link
Contributor Author

wesm commented Sep 8, 2017

I have not made use of any of the direct-to-CUDA serialization code in Arrow yet. I think it would be better to scrutinize that patch more carefully in isolation

@wesm wesm changed the title WIP: Migrate Arrow-related code to incorporate IPC code improvements since 0.4.x Migrate Arrow-related code to incorporate IPC code improvements since 0.4.x, simplifications and perf improvements Sep 8, 2017
@asuhan
Copy link
Contributor

asuhan commented Sep 8, 2017

I agree we should leave the CUDA parts for later. We should also remove the dependency on the Arrow GPU, scripts/common-functions.sh doesn't build with GPU support, which breaks the CUDA build.

The patch looks good otherwise, I'll pick it with the dependency on Arrow GPU removed for now. Thanks!

@asuhan asuhan merged commit 046d876 into heavyai:master Sep 8, 2017
@wesm
Copy link
Contributor Author

wesm commented Sep 8, 2017

Oops, sorry about that (didn't test the toolchain from scratch). Thanks!

@wesm wesm deleted the arrow-0.7-arrow_gpu branch September 8, 2017 19:24
anton-malakhov pushed a commit to anton-malakhov/omniscidb that referenced this pull request Aug 10, 2020
…-dbe-install

remove editable dbe install by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants