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

[GLUTEN-7837][VL] Spark driver should not initialize cache if not in local mode #7853

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

leoluan2009
Copy link
Contributor

@leoluan2009 leoluan2009 commented Nov 7, 2024

What changes were proposed in this pull request?

Fixes: #7837

Spark driver should not initialize cache if not in local mode

How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)

(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)

@github-actions github-actions bot added the VELOX label Nov 7, 2024
Copy link

github-actions bot commented Nov 7, 2024

Thanks for opening a pull request!

Could you open an issue for this pull request on Github Issues?

https://github.com/apache/incubator-gluten/issues

Then could you also rename commit message and pull request title in the following format?

[GLUTEN-${ISSUES_ID}][COMPONENT]feat/fix: ${detailed message}

See also:

@leoluan2009 leoluan2009 changed the title [VL]Add isDriver_ member variables in VeloxBackend class [VL]Add isDriver_ member variable in VeloxBackend class Nov 7, 2024
@leoluan2009 leoluan2009 changed the title [VL]Add isDriver_ member variable in VeloxBackend class [VL] Add isDriver_ member variable in VeloxBackend class Nov 7, 2024
@leoluan2009
Copy link
Contributor Author

@zhztheplayer can you help review?

@zhztheplayer zhztheplayer changed the title [VL] Add isDriver_ member variable in VeloxBackend class [GLUTEN-7837][VL] Add isDriver_ member variable in VeloxBackend class Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

#7837

@zhztheplayer
Copy link
Member

@leoluan2009 Does this solve the cache issue mentioned in #7837?

@leoluan2009
Copy link
Contributor Author

@leoluan2009 Does this solve the cache issue mentioned in #7837?

Yes, if VeloxBackend is running in driver, it will not init cache.

Copy link
Member

@zhztheplayer zhztheplayer left a comment

Choose a reason for hiding this comment

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

How does the change work with Spark local mode? I mean we may need to turn the cache on in local mode if user doesn't explicitly disable it.

@@ -195,7 +195,7 @@ void VeloxBackend::initJolFilesystem() {
}

void VeloxBackend::initCache() {
if (backendConf_->get<bool>(kVeloxCacheEnabled, false)) {
if (backendConf_->get<bool>(kVeloxCacheEnabled, false) && !isDriver_) {
Copy link
Member

Choose a reason for hiding this comment

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

Could just change from the caller code, something like:

if (!isDriver_) {
  initCache();
}
...

Would be enough and more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@zhztheplayer
Copy link
Member

zhztheplayer commented Nov 12, 2024

Hi @leoluan2009 , as spark.gluten.sql.columnar.backend.velox.cacheEnabled is now a static SQL conf, can we just modify the config map passed to native to set it to false from non-local driver side? It's a workaround and we can remove once a optimal design is out.

@leoluan2009
Copy link
Contributor Author

Hi @leoluan2009 , as spark.gluten.sql.columnar.backend.velox.cacheEnabled is now a static SQL conf, can we just modify the config map passed to native to set it to false from non-local driver side? It's a workaround and we can remove once a optimal design is out.

it's ok and I will update the pr

@leoluan2009 leoluan2009 changed the title [GLUTEN-7837][VL] Add isDriver_ member variable in VeloxBackend class [GLUTEN-7837][VL] Spark driver should not init velox cache in local mode Nov 13, 2024
@leoluan2009 leoluan2009 changed the title [GLUTEN-7837][VL] Spark driver should not init velox cache in local mode [GLUTEN-7837][VL] Spark driver should not initialize velox cache in local mode Nov 13, 2024
@leoluan2009 leoluan2009 changed the title [GLUTEN-7837][VL] Spark driver should not initialize velox cache in local mode [GLUTEN-7837][VL] Spark driver should not initialize cache if not in local mode Nov 13, 2024
@leoluan2009
Copy link
Contributor Author

@zhztheplayer I have updated this PR, please help to review, thanks!

val parsed = GlutenConfigUtil.parseConfig(conf.getAll.toMap)
var parsed = GlutenConfigUtil.parseConfig(conf.getAll.toMap)
if (isDriver && !inLocalMode(conf)) {
parsed += (GlutenConfig.COLUMNAR_VELOX_CACHE_ENABLED.key -> "false")
Copy link
Member

Choose a reason for hiding this comment

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

Would you like to add some comments in code? Or just leave a link to the relevant issue/PR. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks

Copy link
Member

@zhztheplayer zhztheplayer left a comment

Choose a reason for hiding this comment

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

👍

@leoluan2009
Copy link
Contributor Author

leoluan2009 commented Nov 14, 2024

@zhztheplayer resolved all comments

@FelixYBW
Copy link
Contributor

@zhztheplayer @leoluan2009
can you go through all the initializations there? Is there any other things we shouldn't run on driver? Is the local cache only exception? I'd expect the initialization should be much different.

If we have more than one, we should considered to seperate the initialization routine for driver and worker.

@zhztheplayer
Copy link
Member

can you go through all the initializations there? Is there any other things we shouldn't run on driver? Is the local cache only exception? I'd expect the initialization should be much different.

Not much difference so far and it's also about our C++ API's encapsulation. We can make trade-offs once it's really needed.

@zhztheplayer zhztheplayer merged commit fd716bf into apache:main Nov 15, 2024
44 checks passed
@zhztheplayer
Copy link
Member

If we have more than one, we should considered to seperate the initialization routine for driver and worker.

In future there will be different ways to implement differentiated initialization, but exposing Spark arch conceptions "driver" / "executor" / "task" to C++ code could be the last ones to consider. We can use configurations, or compose finer-grained JNI initialization APIs, etc.

@FelixYBW
Copy link
Contributor

In future there will be different ways to implement differentiated initialization, but exposing Spark arch conceptions "driver" / "executor" / "task" to C++ code could be the last ones to consider. We can use configurations, or compose finer-grained JNI initialization APIs, etc.

Let's re-evaluate the mythology once we have another exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VL] VeloxBackend should know it run in executor or driver
5 participants