You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2019/10/08 05:44:17 UTC

[jira] [Resolved] (SPARK-23650) Slow SparkR udf (dapply)

     [ https://issues.apache.org/jira/browse/SPARK-23650?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hyukjin Kwon resolved SPARK-23650.
----------------------------------
    Resolution: Incomplete

> Slow SparkR udf (dapply)
> ------------------------
>
>                 Key: SPARK-23650
>                 URL: https://issues.apache.org/jira/browse/SPARK-23650
>             Project: Spark
>          Issue Type: Improvement
>          Components: Spark Shell, SparkR, Structured Streaming
>    Affects Versions: 2.2.0
>            Reporter: Deepansh
>            Priority: Major
>              Labels: bulk-closed
>         Attachments: packageReload.txt, read_model_in_udf.txt, sparkR_log2.txt, sparkRlag.txt
>
>
> For eg, I am getting streams from Kafka and I want to implement a model made in R for those streams. For this, I am using dapply.
> My code is:
> iris_model <- readRDS("./iris_model.rds")
> randomBr <- SparkR:::broadcast(sc, iris_model)
> kafka <- read.stream("kafka",subscribe = "source", kafka.bootstrap.servers = "localhost:9092", topic = "source")
> lines<- select(kafka, cast(kafka$value, "string"))
> schema<-schema(lines)
> df1<-dapply(lines,function(x){
> i_model<-SparkR:::value(randomMatBr)
> for (row in 1:nrow(x))
> { y<-fromJSON(as.character(x[row,"value"])) y$predict=predict(i_model,y) y<-toJSON(y) x[row,"value"] = y }
> x
> },schema)
> Every time when Kafka streams are fetched the dapply method creates new runner thread and ships the variables again, which causes a huge lag(~2s for shipping model) every time. I even tried without broadcast variables but it takes same time to ship variables. Can some other techniques be applied to improve its performance?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org