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

Potential (CPU) performance improvement when publishing #2295

Open
MV-GH opened this issue Dec 19, 2024 · 0 comments · May be fixed by #2304
Open

Potential (CPU) performance improvement when publishing #2295

MV-GH opened this issue Dec 19, 2024 · 0 comments · May be fixed by #2304
Assignees
Labels
api: pubsub Issues related to the googleapis/java-pubsub API.

Comments

@MV-GH
Copy link

MV-GH commented Dec 19, 2024

I was profiling a pubsub benchmark and I saw a potential improvement. Each publish it parses the topicName. 90% of publish CPU time is spent on this. 30% of total CPU during my profiling. One could lift this up into the publisher and pass TopicName directly into PubsubMessageWrapper in the publish

image

Short Repro

val sessionSampleMsg = """{"website":"https://minty-modernist.name","domain":"limp-effector.com","job":{"title":"Investor Creative Administrator","descriptor":"Customer","area":"Accountability","type":"Consultant","company":"Bailey - Ledner"},"uuid":"1ef60952-c540-47ad-97c3-e923e20faafc","objectId":"67643b6bac95a0492808f66b"}"""

val samplePubsubMsg = PubsubMessage.newBuilder()
    .setData(ByteString.copyFromUtf8(sessionSampleMsg))
    .build()

val testTopic = "projects/test/topics/pst-test"
val optimalPublisher = Publisher.newBuilder(testTopic)

fun startProducing(publisher: Publisher) {
    while (true){
        publisher.publish(samplePubsubMsg)
    }
}

fun main() {
  startProducing(optimalPublisher)
}

Profile background

Was run on 2vpcu xeon + 4GB ram, LTS JDK 21

I have included the profile, see below
optimal-producer.zip

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/java-pubsub API. label Dec 19, 2024
@MV-GH MV-GH linked a pull request Jan 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/java-pubsub API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants