Introduction
Hello, we are the mercari.go staff, kobaryo, and earlgray.
On September 19th, we hosted a Go study session called mercari.go #27 via a YouTube online broadcast. In this article, we’ll briefly introduce each presentation from that day. The videos have also been uploaded, so please look at them as well.
Writing profitable tests in Go
The first session was “Writing profitable tests in Go“ by @kinbiko.
Presentation material: Writing profitable tests in Go
The session introduced the theme of testing in Go from the perspective of profitability. In this session, @kinbiko introduced the rules for deciding whether to write tests and techniques for describing tests in Go. Tests are useful not only for verifying the behavior of code but also for ensuring that future changes do not cause issues.
However, tests cause costs in terms of writing time and execution, so it is important to justify these costs. You can do this by calculating the expected impact of the lack of a test, based on your organization’s historical incident impact and engineering salaries multiplied by the probability of needing to spend time on incident handling / debugging as a result of a missing test.
Additionally, tips were provided, such as the benefits of improving readability and code quality in Go tests, and the drawbacks of forcing the use of table-driven tests where separate subtests are more readable. Various other tips were introduced, so if you’re interested, please take a look. Table-driven tests are often seen in Go, and many people tend to write in this style. I was also one of them, but this time, I was able to understand their advantages and disadvantages, so I want to use them in appropriate use cases going forward. (earlgray)
GC24 Recap: Interface Internals
The second session was “GC24 Recap: Interface Internals” by @task4233.
Presentation material: GC24 Recap: Interface Internals
In this session, as a recap of the “Interface Internals” presentation at GopherCon 2024, the speaker explained how function calls through interfaces are executed, using a debugger to see values in memory.
When a Go program is compiled to assembly, we can understand that the function is invoked by a call instruction with an argument that is the memory address where the function’s processing is written. However, since a method call via an interface dynamically selects the function to be invoked, this mechanism cannot be used as is. This session started with explaining the data structures that implement interfaces, followed by the method to determine the address of the called method and techniques to speed up this process.
As the content of this presentation is deep and core part of the Go language, I personally felt the need to read references and watch it multiple times to properly understand it. (kobaryo)
GC24 Recap: Who Tests the Tests?
The third session was “GC24 Recap: Who Tests the Tests?” by @Ruslan.
Presentation material: GC24 Recap: Who Tests the Tests?
This session, like the second GC24 Recap: Interface Internals, was a recap of GopherCon 2024, covering the content of “Who Tests the Tests?”
We use test coverage as an indicator of software quality, but it does not guarantee the quality of the tests themselves. This session introduced Mutation Testing to ensure the quality of tests. By using this technique, it can be checked whether tests fail when operators or boolean values in a program are changed, ensuring that the tests only pass the correct program. Additionally, the method of automatically generating such programs using the AST package was explained.
The session provided fascinating content about ensuring the quality of the tests themselves, and it was highly practical, making it a very beneficial session. Readers of this blog might also consider introducing this technique. (kobaryo)
Cloud Pub/Sub – High Speed In-App Notification Delivery
The fourth session was “Cloud Pub/Sub – High Speed In-App Notification Delivery“ by @akram.
Presentation material: Cloud Pub/Sub – High Speed In-App Notification Delivery
A case study on the utilization of Cloud Pub/Sub in the Notification platform for managing notifications at Mercari was introduced. At Mercari, notifications such as in-app alerts, To-Do lists, emails, and Push notifications are sent to customers. To achieve performance that enables real-time and asynchronous notifications to over 20 million customers, the notification platform uses Cloud Pub/Sub. Specifically, the notification process is handled by a two-server configuration: one server receives Push notification requests and publishes them to Pub/Sub, and the other subscribes to Pub/Sub and performs the actual notifications. As a result, Mercari currently achieves more than 16 million Push notifications per day (400 rps at peak).
This was a very interesting insight into the use of Pub/Sub in a large-scale platform like Mercari. If you are experiencing performance challenges with handling asynchronous tasks, considering the introduction of Pub/Sub might be worthwhile. (earlgray)
Conclusion
This time, we delivered four presentations ranging from core aspects of the Go language to practical techniques. There were also presentations about GopherCon 2024, which were very educational for the organizing members as they learned about the latest developments in Go.
Thank you very much to those who watched live or recording!
Please look forward to the next event! If you want to receive event announcements, please become a member of our connpass group!