checkpoint: بریدنِ یه lineage که از کنترل خارج شده
توی pipelineهای تکرارشونده، plan منطقی اونقدر بزرگ میشه که کارِت به StackOverflow یا بازمحاسبه انفجاری میکشه؛ checkpoint این شجره رو میبُره.
کاربرد
حلقههای غنیسازی پشت سر هم، الگوریتمهای تکرارشونده روی DataFrameها.
پیشنیازها
PySpark 3.x
Python
spark.sparkContext.setCheckpointDir("s3a://lake/tmp/checkpoints")
df_iter = seed
for i, rules in enumerate(rule_batches):
df_iter = apply_rules(df_iter, rules)
if i % 10 == 9:
# Écrit sur stockage fiable et REPART d'un plan vide
df_iter = df_iter.checkpoint(eager=True)
# localCheckpoint() : plus rapide (disque executor) mais perdu si un
# executor meurt — acceptable en exploratoire, pas en production.
# Alternative robuste et explicite : write.parquet(tmp) puis read.parquet(tmp).نتیجه
iteration 04 plan: 1248 noeuds batch: 96 s iteration 09 plan: 2730 noeuds batch: 311 s -- checkpoint(eager=True) : ecriture 38 s, plan tronque -- iteration 10 plan: 12 noeuds batch: 41 s iteration 19 plan: 1304 noeuds batch: 102 s -- checkpoint(eager=True) : ecriture 39 s, plan tronque -- Sans checkpoint : StackOverflowError a l'iteration 23.
PySparkcheckpointLineageItératif