You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "iasonS (via GitHub)" <gi...@apache.org> on 2026/03/23 15:37:30 UTC
[I] Dataset.localCheckpoint() should accept a StorageLevel parameter [spark]
iasonS opened a new issue, #54954:
URL: https://github.com/apache/spark/issues/54954
**What problem does this solve?**
`Dataset.localCheckpoint()` always checkpoints using `MEMORY_AND_DISK` regardless of what you pass to `persist()` beforehand. It creates a fresh internal RDD via `queryExecution.toRdd.map(_.copy())`, which has no storage level set, so `RDD.localCheckpoint()` always falls through to the default.
Calling `dataset.persist(StorageLevel.DISK_ONLY).localCheckpoint()` ends up with two separate storage copies -- the SQL CacheManager entry at `DISK_ONLY` and the checkpoint RDD at `MEMORY_AND_DISK`. For large datasets this is a real OOM problem.
**Current workaround**
Drop to the RDD API:
```scala
val rdd = dataset.rdd
rdd.persist(StorageLevel.DISK_ONLY)
rdd.localCheckpoint()
rdd.count()
val result = spark.createDataFrame(rdd, dataset.schema)
```
This works because `RDD.localCheckpoint()` checks if a storage level is already set and calls `persist(transformStorageLevel(existing))`, so `doCheckpoint()` finds the blocks already in the BlockManager and skips writing a second copy. But you lose Tungsten/UnsafeRow format in the process, which is a real performance tradeoff.
**Proposed change**
Add a `storageLevel` parameter to `Dataset.localCheckpoint()`:
```scala
def localCheckpoint(eager: Boolean = true, storageLevel: StorageLevel = LocalRDDCheckpointData.DEFAULT_STORAGE_LEVEL): Dataset[T]
```
Internally, instead of letting the fresh internal RDD default to `MEMORY_AND_DISK`, call `persist(transformStorageLevel(storageLevel))` on it before materializing. One copy at the level the user asked for, lineage cut, Tungsten preserved.
--
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: reviews-unsubscribe@spark.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [I] Dataset.localCheckpoint() should accept a StorageLevel parameter [spark]
Posted by "iasonS (via GitHub)" <gi...@apache.org>.
iasonS commented on issue #54954:
URL: https://github.com/apache/spark/issues/54954#issuecomment-4113067513
Closing — this was already addressed in Spark 4.0.0. `Dataset.localCheckpoint(eager: Boolean, storageLevel: StorageLevel)` was added with `@since 4.0.0` and handles this correctly.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [I] Dataset.localCheckpoint() should accept a StorageLevel parameter [spark]
Posted by "iasonS (via GitHub)" <gi...@apache.org>.
iasonS closed issue #54954: Dataset.localCheckpoint() should accept a StorageLevel parameter
URL: https://github.com/apache/spark/issues/54954
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org