-
Notifications
You must be signed in to change notification settings - Fork 4
CORE-207: optimize stringToTypedAttribute in TSV upload #1519
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
61 changes: 61 additions & 0 deletions
61
...arks/src/main/scala/org/broadinstitute/dsde/firecloud/utils/TsvFileSupportBenchmark.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,61 @@ | ||
package org.broadinstitute.dsde.firecloud.utils | ||
|
||
import org.broadinstitute.dsde.firecloud.model.{EntityUpdateDefinition, FlexibleModelSchema, ModelSchema} | ||
import org.broadinstitute.dsde.firecloud.service.TSVFileSupport | ||
import org.broadinstitute.dsde.firecloud.utils.TsvFileSupportBenchmark.TsvData | ||
import org.openjdk.jmh.annotations.{Benchmark, Scope, State} | ||
import org.openjdk.jmh.infra.Blackhole | ||
|
||
object TsvFileSupportBenchmark { | ||
@State(Scope.Thread) | ||
class TsvData { | ||
val entityType: String = "sample" | ||
val memberTypeOpt: Option[String] = None | ||
// representation of the inbound TSV row | ||
val row: Seq[String] = Seq( | ||
"0005", | ||
"foo", | ||
"\"some\tquoted\tvalue\"", | ||
"42", | ||
"true", | ||
"-123.456", | ||
"gs://some-bucket/somefile.ext", | ||
"""{"entityType":"targetType", "entityName":"targetName"}""", | ||
"[1,2,3,4,5]" | ||
) | ||
val colInfo: Seq[(String, Option[String])] = Seq( | ||
("sample_id", None), | ||
("string", None), | ||
("quotedstring", None), | ||
("int", None), | ||
("boolean", None), | ||
("double", None), | ||
("file", None), | ||
("reference", None), | ||
("array", None) | ||
) | ||
val modelSchema: ModelSchema = FlexibleModelSchema | ||
val deleteEmptyValues: Boolean = false | ||
} | ||
} | ||
|
||
class TsvFileSupportBenchmark { | ||
|
||
@Benchmark | ||
def makeEntityRows(blackHole: Blackhole, tsvData: TsvData): EntityUpdateDefinition = { | ||
|
||
val result: EntityUpdateDefinition = TsvFileSupportHarness.setAttributesOnEntity(tsvData.entityType, | ||
tsvData.memberTypeOpt, | ||
tsvData.row, | ||
tsvData.colInfo, | ||
tsvData.modelSchema, | ||
tsvData.deleteEmptyValues | ||
) | ||
blackHole.consume(result) | ||
result | ||
} | ||
|
||
} | ||
|
||
// helper object to get access to TSVFileSupport trait | ||
object TsvFileSupportHarness extends TSVFileSupport {} |
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
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.
The early exits bother me in scala code so I asked copilot to rewrite using
collectFirst
and this is what it came up with.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.
@dvoet I've rewritten to be more idiomatic - what do you think?