You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "yekebit (via GitHub)" <gi...@apache.org> on 2024/03/26 02:38:50 UTC
[I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
yekebit opened a new issue, #10924:
URL: https://github.com/apache/hudi/issues/10924
As the title says, I want to know how to run the file named “hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/execution/benchmark/LSMTimelineReadBenchmark.scala” in spark to test LSMTimline.
Unfortunately, I don't know much about hudi testing yet.
The content of LSMTimelineReadBenchmark.scala is as follows:
```scala
/*
* 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.spark.sql.execution.benchmark
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.Path
import org.apache.hudi.DummyActiveAction
import org.apache.hudi.client.common.HoodieJavaEngineContext
import org.apache.hudi.client.timeline.LSMTimelineWriter
import org.apache.hudi.common.model.{HoodieAvroPayload, HoodieCommitMetadata, HoodieTableType, WriteOperationType}
import org.apache.hudi.common.table.timeline.TimelineMetadataUtils.serializeCommitMetadata
import org.apache.hudi.common.table.timeline.{ActiveAction, HoodieArchivedTimeline, HoodieInstant, LSMTimeline}
import org.apache.hudi.common.testutils.{HoodieTestTable, HoodieTestUtils}
import org.apache.hudi.config.{HoodieIndexConfig, HoodieWriteConfig}
import org.apache.hudi.index.HoodieIndex.IndexType
import org.apache.hudi.table.HoodieJavaTable
import org.apache.spark.hudi.benchmark.{HoodieBenchmark, HoodieBenchmarkBase}
import java.util
import scala.collection.JavaConverters._
object LSMTimelineReadBenchmark extends HoodieBenchmarkBase {
/**
* Java HotSpot(TM) 64-Bit Server VM 1.8.0_351-b10 on Mac OS X 13.4.1
* Apple M2
* pref load archived instants: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
* ------------------------------------------------------------------------------------------------------------------------
* read shim instants 18 32 15 0.1 17914.8 1.0X
* read instants with commit metadata 19 25 5 0.1 19403.1 0.9X
*/
private def readArchivedInstantsBenchmark(): Unit = {
withTempDir(f => {
val tableName = "testTable"
val tablePath = new Path(f.getCanonicalPath, tableName).toUri.toString
val metaClient = HoodieTestUtils.init(new Configuration(), tablePath, HoodieTableType.COPY_ON_WRITE, tableName)
val writeConfig = HoodieWriteConfig.newBuilder().withPath(tablePath)
.withIndexConfig(HoodieIndexConfig.newBuilder().withIndexType(IndexType.INMEMORY).build())
.withMarkersType("DIRECT")
.build()
val engineContext = new HoodieJavaEngineContext(new Configuration())
val writer = LSMTimelineWriter.getInstance(writeConfig, HoodieJavaTable.create(writeConfig, engineContext).asInstanceOf[HoodieJavaTable[HoodieAvroPayload]])
val startTs = System.currentTimeMillis()
val startInstant = startTs + 1 + ""
val commitsNum = 10000000
val batchSize = 2000
val instantBuffer = new util.ArrayList[ActiveAction]()
for (i <- 1 to commitsNum) {
val instantTime = startTs + i + ""
val action = if (i % 2 == 0) "delta_commit" else "commit"
val instant = new HoodieInstant(HoodieInstant.State.COMPLETED, action, instantTime, instantTime + 1000)
val metadata: HoodieCommitMetadata = HoodieTestTable.of(metaClient).createCommitMetadata(instantTime, WriteOperationType.INSERT, util.Arrays.asList("par1", "par2"), 10, false)
val serializedMetadata = serializeCommitMetadata(metadata).get()
instantBuffer.add(new DummyActiveAction(instant, serializedMetadata))
if (i % batchSize == 0) {
// archive 10 instants each time
writer.write(instantBuffer, org.apache.hudi.common.util.Option.empty(), org.apache.hudi.common.util.Option.empty())
writer.compactAndClean(engineContext)
instantBuffer.clear()
}
}
val benchmark = new HoodieBenchmark("pref load archived instants", commitsNum, 3)
benchmark.addCase("read slim instants") { _ =>
new HoodieArchivedTimeline(metaClient)
}
benchmark.addCase("read instants with commit metadata") { _ =>
new HoodieArchivedTimeline(metaClient, startInstant)
}
benchmark.run()
val totalSize = LSMTimeline.latestSnapshotManifest(metaClient).getFiles.asScala
.map(f => f.getFileLen)
.sum
println("Total file size in bytes: " + totalSize)
})
}
override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
readArchivedInstantsBenchmark()
}
}
```
--
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: commits-unsubscribe@hudi.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "ad1happy2go (via GitHub)" <gi...@apache.org>.
ad1happy2go closed issue #10924: [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ?
URL: https://github.com/apache/hudi/issues/10924
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "yekebit (via GitHub)" <gi...@apache.org>.
yekebit commented on issue #10924:
URL: https://github.com/apache/hudi/issues/10924#issuecomment-2019530921
@danny0405 I looked at your homepage, you should be Chinese, so I spoke Chinese, of course, if you don't like this, or in English communication
I see a web page, I don't know if according to this web page to match up hudi development environment:
> https://hudi.apache.org/contribute/developer-setup/
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #10924:
URL: https://github.com/apache/hudi/issues/10924#issuecomment-2019891725
You can just run the benchmark on local env. And you can switch the table dir to the storage you already set up to, the execution can always be in local.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "yekebit (via GitHub)" <gi...@apache.org>.
yekebit commented on issue #10924:
URL: https://github.com/apache/hudi/issues/10924#issuecomment-2019454130
@danny0405 I am so sorry, but I still don't know how to run it in local as a unit test. Could you teach me, please.
I read the Readme.md of Hudi and there are some information about test, as shown in the image below. I don't know whether I should run these command without any modification. I sincerely hope you can give me some concrete instruction. Looking forward to your reply.

--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #10924:
URL: https://github.com/apache/hudi/issues/10924#issuecomment-2019305095
Just run it in local as a UT.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "yekebit (via GitHub)" <gi...@apache.org>.
yekebit commented on issue #10924:
URL: https://github.com/apache/hudi/issues/10924#issuecomment-2019519477
@danny0405 大佬您好,我使用的是学校的服务器(ubuntu)搭建的这个hudi,我自己用windows的电脑用ssh软件连接的,我想我应该可以在我的windows电脑上远程连接服务器上的这个hudi然后来运行吧
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [SUPPORT] How to run org.apache.spark.sql.execution.benchmark.LSMTimelineReadBenchmark ? [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #10924:
URL: https://github.com/apache/hudi/issues/10924#issuecomment-2019516340
I'm using IDEA and just click the `run` button.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org