-
Notifications
You must be signed in to change notification settings - Fork 632
[GLUTEN-12621][CORE] Fix NoSuchElementException in untracked memory mode without off-heap size #12622
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
Open
LuciferYang
wants to merge
1
commit into
apache:main
Choose a base branch
from
LuciferYang:fix/untracked-offheap-nosuchelement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−1
Open
[GLUTEN-12621][CORE] Fix NoSuchElementException in untracked memory mode without off-heap size #12622
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
gluten-core/src/test/scala/org/apache/gluten/GlutenDriverPluginSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.gluten | ||
|
|
||
| import org.apache.gluten.config.GlutenCoreConfig | ||
|
|
||
| import org.apache.spark.SparkConf | ||
|
|
||
| import org.scalatest.funsuite.AnyFunSuite | ||
|
|
||
| class GlutenDriverPluginSuite extends AnyFunSuite { | ||
|
|
||
| test("setPredefinedConfigs does not throw in untracked mode without an off-heap size") { | ||
| // Untracked memory mode skips the off-heap size requirement in checkOffHeapSettings, so | ||
| // spark.memory.offHeap.size may be absent. setPredefinedConfigs must not read it with the | ||
| // single-arg getSizeAsBytes, which throws NoSuchElementException on a missing key. | ||
| val conf = new SparkConf(false) | ||
| .set("spark.master", "local[1]") | ||
| .set(GlutenCoreConfig.COLUMNAR_MEMORY_UNTRACKED.key, "true") | ||
| GlutenDriverPlugin.setPredefinedConfigs(conf) | ||
| assert(conf.getLong(GlutenCoreConfig.COLUMNAR_OFFHEAP_SIZE_IN_BYTES.key, -1L) == 0L) | ||
| // The raw key is normalized to 0 so downstream readers (e.g. VeloxListenerApi.onDriverStart) | ||
| // that call the single-arg getSizeAsBytes don't hit NoSuchElementException later. | ||
| assert(conf.getSizeAsBytes(GlutenCoreConfig.SPARK_OFFHEAP_SIZE_KEY) == 0L) | ||
| } | ||
|
|
||
| test("setPredefinedConfigs reads the configured off-heap size in the normal path") { | ||
| val conf = new SparkConf(false) | ||
| .set("spark.master", "local[1]") | ||
| .set(GlutenCoreConfig.SPARK_OFFHEAP_ENABLED_KEY, "true") | ||
| .set(GlutenCoreConfig.SPARK_OFFHEAP_SIZE_KEY, "512m") | ||
| GlutenDriverPlugin.setPredefinedConfigs(conf) | ||
| assert( | ||
| conf.getLong(GlutenCoreConfig.COLUMNAR_OFFHEAP_SIZE_IN_BYTES.key, -1L) == 512L * 1024 * 1024) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have checked the offHeap size while initing GlutenPlugin, this seems un neccesary? or we have any cases that meet this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still needed for untracked mode. You're right that we validate the off-heap size in
checkOffHeapSettings, but that path only runs in normal mode: untracked mode returns early at L86-89 (theCOLUMNAR_MEMORY_UNTRACKEDbranch), before the L92-102 size check, sospark.memory.offHeap.sizecan stay absent.Repro:
spark.gluten.memory.untracked=truewithspark.memory.offHeap.sizeunset and dynamic sizing off →checkOffHeapSettingsreturns at L89 → the else-branch (main L136) calls the single-argconf.getSizeAsBytes(SPARK_OFFHEAP_SIZE_KEY), which throwsNoSuchElementExceptionbecauseSparkConf.get(String)reads the raw settings map and doesn't fall back to the ConfigEntry default. The addedGlutenDriverPluginSuitetest "setPredefinedConfigs does not throw in untracked mode without an off-heap size" fails without this change.If it reads clearer, I can add a short comment at the untracked early-return noting the size isn't validated there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm this reproduces on the real driver-init path and not only in the unit test:
With
spark.plugins=org.apache.gluten.GlutenPlugin,spark.gluten.memory.untracked=true, andspark.memory.offHeap.sizeleft unset, constructing aSparkContextrunsGlutenDriverPlugin.init->setPredefinedConfigsand fails with:I checked this locally by wiring a test through
new SparkContext(conf)with the realspark.pluginsregistration. It fails on the unfixed tree with that exception and passes with this change.There are three places a boot-based test could live, each with a cost:
Direct call to
setPredefinedConfigs(what this PR does). Same input state and same throwing line as the real path, runs ingluten-corewith no extra setup. It just does not enter throughinit.Full
SparkContextboot ingluten-core.GlutenDriverPlugin.initcallsComponent.sorted(), which needs at least oneMETA-INF/gluten-componentsfile on the classpath, andgluten-coreships none (real backends live in the backend modules), so this needs a test-only dummy backend and a registration resource.Componentalso keeps a JVM-global graph with a one-shot load latch and no reset, andComponentSuiteregisters an intentional dependency cycle without cleaning it up, so a boot suite sharing the test JVM hitsUnsupportedOperationException: Cycle detected in the component graph. Making it stable needs a testing-onlyComponentreset hook, withShuffleManagerRegistry.clear()guarded bySparkTestUtil.isTestingas the precedent.Integration test in a backend module like
backends-velox. That module ships a realVeloxBackendcomponent file and has no graph-polluting suite, so a realspark.pluginsboot works there without any of the option 2 machinery. The cost is that it goes throughVeloxListenerApi.onDriverStart, so it needs the native build and only runs in CI, and the test would sit in a different module than the one-line fix.I lean toward option 1 for this fix, and option 3 if we want a production-level boot test. Fine either way, tell me which you prefer.