Skip to content

Conversation

@kszucs
Copy link
Member

@kszucs kszucs commented Jan 25, 2019

We were not running the pyarrow tests after installing the manylinux wheels, which can lead to uncaught issues, like: https://travis-ci.org/kszucs/crossbow/builds/484284104

@kszucs
Copy link
Member Author

kszucs commented Jan 28, 2019

@xhochy We're not bundling gandiva generated bytecode files. I'm trying to resolve it, but You might know the solution.

@kszucs
Copy link
Member Author

kszucs commented Jan 28, 2019

I've managed to bundle irhelpers.bc as gandiva_irhelpers.bc in the python package, but We still need configure the engine accordingly, bot only for wheels.

@xhochy
Copy link
Member

xhochy commented Jan 28, 2019

but We still need configure the engine accordingly

What do you mean with that?

@wesm
Copy link
Member

wesm commented Jan 28, 2019

I think the bitcode path is still being hard-coded, is that right?

@kszucs
Copy link
Member Author

kszucs commented Jan 28, 2019

@xhochy according to this commit @kou made it configurable.

@kou
Copy link
Member

kou commented Jan 28, 2019

The change just for creating a configuration for custom path. This is enough just for testing. But it's not suitable for normal use.
We can't change the default path yet. I think that we need a feature to customize the default path dynamically or finding the byte code path from the loaded shared library path or something.

.travis.yml Outdated
Copy link
Member Author

Choose a reason for hiding this comment

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

This will reduce the build times. There are nightly tests for all versions.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pitrou This will resolve the random timeouts of wheel builds.

@kszucs
Copy link
Member Author

kszucs commented Jan 29, 2019

@kou could You elaborate on customizing the default path dynamically?

If I understand correctly the second option is to maintain a list of default search paths relative to the gandiva binary (queried via dladdr or boost::dll::program_location())?;

@kou
Copy link
Member

kou commented Jan 29, 2019

could You elaborate on customizing the default path dynamically?

The easiest way is using an environment variable:

diff --git a/cpp/src/gandiva/configuration.h b/cpp/src/gandiva/configuration.h
index 04e2eed2..fd948400 100644
--- a/cpp/src/gandiva/configuration.h
+++ b/cpp/src/gandiva/configuration.h
@@ -75,7 +75,14 @@ class ConfigurationBuilder {
   std::string byte_code_file_path_;
 
   static std::shared_ptr<Configuration> InitDefaultConfig() {
-    std::shared_ptr<Configuration> configuration(new Configuration(kByteCodeFilePath));
+    std::string path;
+    auto path_env = std::getenv("GANDIVA_BYTE_CODE_PATH");
+    if (path_env) {
+      path = path_env;
+    } else {
+      path = kByteCodeFilePath;
+    }
+    std::shared_ptr<Configuration> configuration(new Configuration(path));
     return configuration;
   }

But it may have a security problem.

@kou
Copy link
Member

kou commented Jan 29, 2019

If I understand correctly the second option is to maintain a list of default search paths relative to the gandiva binary (queried via dladdr or boost::dll::program_location())?

Right. But it may be difficult. Because Gandiva may be built as a static library. (We may able to assume that Gandiva is built as a shared library in wheel.)

This approach is popular on Windows. Many products search their configuration file by relative path from their DLL.
But it's not popular on Linux.

@kszucs
Copy link
Member Author

kszucs commented Jan 29, 2019

@wesm any thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

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

Aren't we crashy when Tensorflow is loaded in the same process?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess this is supposed to test that.

Copy link
Member

Choose a reason for hiding this comment

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

We should not crash, there is some special safeaguarding code for that.

Copy link
Member

Choose a reason for hiding this comment

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

But it doesn't always work, see https://issues.apache.org/jira/browse/ARROW-4272

Copy link
Member

Choose a reason for hiding this comment

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

So shouldn't we remove this import?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why should We? If We want to test that both arrow and tensorflow can live in the same interperter.

Copy link
Member

Choose a reason for hiding this comment

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

As you prefer... but it will probably fail at one point or the other, because Tensorflow publishes rogue wheels.

@kszucs
Copy link
Member Author

kszucs commented Jan 31, 2019

@pravindra couldn't We embed the bitcode into the library?

@pravindra
Copy link
Contributor

@pravindra couldn't We embed the bitcode into the library?

sorry, I didn't understand. can you please elaborate some more ? The bit-code file is generated by a series of clang tool commands during the build process. Is there a way to add such a file into the .so or .a, and extract it later at runtime ?

@pitrou
Copy link
Member

pitrou commented Jan 31, 2019

The easiest and most portable way (though slightly clunky) would probably to generate a C++ file containing static const char arrays of the embedded bitcodes...

See https://stackoverflow.com/questions/11813271/embed-resources-eg-shader-code-images-into-executable-library-with-cmake for an example, though we'd probably want to write the generator utility in Python.

@kszucs
Copy link
Member Author

kszucs commented Jan 31, 2019

@pravindra yes, like Antoine's example. Although it might be easier to just configure the right path from the python module (similarly like from java). Not sure which one would be cleaner...

@kszucs
Copy link
Member Author

kszucs commented Jan 31, 2019

But We still need to keep the ability to load bitcode from files, right?

@pitrou
Copy link
Member

pitrou commented Jan 31, 2019

Apparently the bitcode path is hardcoded as an absolute path currently (see the generated bc_file_path.cc), so the approach would have to be fixed anyway:

namespace gandiva {

// Path to the byte-code file.
extern const char kByteCodeFilePath[] = "/home/antoine/miniconda3/envs/pyarrow/lib/gandiva/irhelpers.bc";

} // namespace gandiva

@kszucs
Copy link
Member Author

kszucs commented Jan 31, 2019

So We have a couple of options:

  • don't set default path at all, and let the binding (java, python) configure it
  • set default path relative to the shared lib (is it fragile in case of static libs?)
  • compile the bitcode as a string into the lib

which one should We go with?

@pitrou
Copy link
Member

pitrou commented Jan 31, 2019

I think compiling the bitcode as a string is the most pain-free approach. Other approaches have to deal with locating the files on disk in different environments (Python, Java, ...).

@kszucs
Copy link
Member Author

kszucs commented Jan 31, 2019

Any downstream libraries would like to provide precompiled gandiva expressions should do the same?

@pitrou
Copy link
Member

pitrou commented Jan 31, 2019

I think that's a separate concern. It would probably be possible to let them choose their preferred way.

@kszucs
Copy link
Member Author

kszucs commented Jan 31, 2019

Ok, I'll go with the string approach then. Thanks @pitrou !

@pravindra
Copy link
Contributor

I do see the advantages of the embed-as-string approach.

Early on, we had plans to support pluggable function registries in gandiva I.e given a new bitcode file and the fn signatures, it would be possible to add new functions to gandiva by doing a module reload (without actually changing arrow/gandiva code). so, passing the location(s) of the bitcode file(s) as a config param made sense.

We didn’t get around to implementing it properly, and I think it’s harder to do now since there are cross references from the bitcode files into gandiva/arrow (for date/decimal).

Embedding the bc code into the library will mean that we cannot go down that path anymore.

@wesm
Copy link
Member

wesm commented Feb 9, 2019

Where do things stand on this?

@kszucs
Copy link
Member Author

kszucs commented Feb 12, 2019

I can continue to work on this tomorrow, right now I'm busy with buildbot's infra.

@kszucs kszucs changed the title ARROW-4372: [Python] Run pyarrow tests in manylinux travis build ARROW-4372: [C++] Embed precompiled bitcode in the gandiva library Feb 15, 2019
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure that We want to hash the precompiled bitcode, so I've disabled it.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe, keep this Hash(), but dummy out the configuration->Hash() (just return 0) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't hash byte_code_file_path anymore, so I plan to remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok if I give you a patch for the test ?

@kszucs
Copy link
Member Author

kszucs commented Feb 20, 2019

We need to ensure that the remaining wheels (OSX and Windows) and conda packages are shipping gandiva as well.
Crossbow builds: https://github.com/kszucs/crossbow/branches/all?query=build-443

@kszucs kszucs requested a review from xhochy February 20, 2019 00:39
@kszucs
Copy link
Member Author

kszucs commented Feb 21, 2019

Follow-up issues:

  • ARROW-4644: [C++/Docker] Build Gandiva in the docker containers
  • ARROW-4645: [C++/Packaging] Ship Gandiva with OSX and Windows wheels
  • ARROW-4646: [C++/Packaging] Ship gandiva with the conda-forge packages

Copy link
Contributor

@pravindra pravindra left a comment

Choose a reason for hiding this comment

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

the gandiva changes LGTM. I skipped over the python changes.

@kszucs
Copy link
Member Author

kszucs commented Feb 21, 2019

Thanks for your review @pravindra!

Copy link
Member

@xhochy xhochy left a comment

Choose a reason for hiding this comment

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

+1, LGTM

@kszucs kszucs closed this in e8cc48b Feb 21, 2019
pribor pushed a commit to GlobalWebIndex/arrow that referenced this pull request Oct 24, 2025
We were not running the pyarrow tests after installing the manylinux wheels, which can lead to uncaught issues, like: https://travis-ci.org/kszucs/crossbow/builds/484284104

Author: Krisztián Szűcs <szucs.krisztian@gmail.com>

Closes apache#3484 from kszucs/manylinux_tests and squashes the following commits:

3b1da30 <Krisztián Szűcs> use sudo
c573a56 <Krisztián Szűcs> use env variables insude the container
fd5e3fe <Krisztián Szűcs> use latest docker image tag
d5531d9 <Krisztián Szűcs> test imports inside the wheel container
1aa19f1 <Krisztián Szűcs> reenable travis builds
b399496 <Krisztián Szűcs> test py27mu and py36m wheels
71233c7 <Krisztián Szűcs> test 2.7,16 wheel
2372f3d <Krisztián Szűcs> fix requirements path; disable other CI tests
3e4ec2a <Krisztián Szűcs> unterminated llvm:MemoryBuffer; fix check_import.py path
7c88d61 <Krisztián Szűcs> only build python 3.6 wheel
18c5488 <Krisztián Szűcs> install wheel from dist dir
0bb07a7 <Krisztián Szűcs> better bash split
54fc653 <Krisztián Szűcs> don't export
d3cb058 <Krisztián Szűcs> fix wheel building script
0d29b31 <Krisztián Szűcs> remove not existing resources from gandiva's pom
5d75adb <Krisztián Szűcs> initialize jni loader
09d829a <Krisztián Szűcs> build wheels for a single python distribution at a time; adjust travis and crossbow scripts
79abc0e <Krisztián Szűcs> mark .cc file as generated
af78be2 <Krisztián Szűcs> don't bundle irhelpers in the jar
a88cd37 <Krisztián Szűcs> cmake format
7deb359 <Krisztián Szűcs> fix REGEX; remove byteCodeFilePath from java configuration object
fa19529 <Krisztián Szűcs> properly construct llvm:StringRef
5841dcd <Krisztián Szűcs> remove commented code
42391b1 <Krisztián Szűcs> don't pass precompiled bitcode all around the constructors
d480c83 <Krisztián Szűcs> use const string ref for now
b0b1117 <Krisztián Szűcs> conda llvmdev
169f43a <Krisztián Szűcs> build gandiva in cpp docker image
cb69625 <Krisztián Szűcs> silent maven download msgs
19200c3 <Krisztián Szűcs> don't run wheel tests twice; cmake format
f2205d0 <Krisztián Szűcs> gandiva jni
dbf5b1c <Krisztián Szűcs> embed precompiled bitcode as char array; load precompiled IR from string
00d98e0 <Krisztián Szűcs> try to bundle bytecode files
97fe94b <Krisztián Szűcs> fix requirements-test.txt path
86e7e5b <Krisztián Szűcs> run pyarrow tests in manylinux CI build
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.

6 participants