Skip to content
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

@W-8295960@ avoid repeated codec factory initialization #526

Merged
merged 2 commits into from
Nov 5, 2020

Conversation

gerashegalov
Copy link
Contributor

@gerashegalov gerashegalov commented Oct 30, 2020

Related issues
#527

Describe the proposed solution
move out as an object field with only default codecs (Gzip and deflate)
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context about the changes here.

@@ -268,6 +268,8 @@ private object WorkflowFileReader {
val rawModel = "rawModel"
val zipModel = "Model.zip"
def modelStagingDir: String = s"modelStagingDir/model-${System.currentTimeMillis}"
val confWithDefaultCodec = new Configuration(false)
val codecFactory = new CompressionCodecFactory(confWithDefaultCodec)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it reusable? Is this thread-safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is.

The codec factory maps are fully populated after the constructor and val is final.
Each usage of the WorkflowReader singleton in a different thread necessarily is synchronized with the classloader static class initialization.

So there is proper JMM happens-before order between the consistent codec factory and the future getCodec lookups.

@gerashegalov gerashegalov changed the title avoid repeated codec factory initialization @W-8295960@ avoid repeated codec factory initialization Oct 31, 2020
@tovbinm tovbinm merged commit bc507f2 into master Nov 5, 2020
@tovbinm tovbinm deleted the gera/codecFactoryFix branch November 5, 2020 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG P1 git2gus P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants