上周再hacker news 上有一篇讨论go enum 的 文章 Go Enums Suck(很开心还能再hacker news 上看到go相关的信息),我不想对这篇文章发表什么看法,作者说的都是正确的 如果把iota 当成enum看,跟其他语言相比较,确实很糟糕,本篇文章,我们讨论一下iota 的用法。

Read more »

Pasted image 20240320201037

Note: Non-members can read the full story in this link.

Introduction

In the previous article, we verified the context switch overhead of Linux processes and threads experimentally, which was approximately between 3-5 microseconds. This overhead is not significant, but for massively concurrent internet servers and typical computer programs, the characteristics are as follows:

  • High concurrency: Thousands to tens of thousands of user requests need to be processed per second.
  • Short cycles: The processing time per user should be as short as possible, often in the millisecond range.
  • High network I/O: Often requires network I/O from other machines, such as Redis, MySQL, etc.
  • Low computation: General CPU-intensive operations are not frequent.
    Read more »

进程是操作系统的伟大发明之一,对应用程序屏蔽了CPU调度、内存管理等硬件细节,而抽象出一个进程的概念,让应用程序专心于实现自己的业务逻辑既可,而且在有限的CPU上可以“同时”进行许多个任务。但是它为用户带来方便的同时,也引入了一些额外的开销。如下图,在进程运行中间的时间里,虽然CPU也在忙于干活,但是却没有完成任何的用户工作,这就是进程机制带来的额外开销。

Read more »

This article is first published in the medium MPP plan. If you are a medium user, please follow me in medium. Thank you very much.

publication即出版物,你可以把他理解成一本杂志,但是可以随时发布,随时修改。
每个 publication都有一个或者多个编辑,这个编辑负责审核你的文章,发表。总体流程 大概就这样子。

Read more »

Go 是一种静态类型的编译语言,它的设计目标是简洁、高效。虽然 Go 不是一种完全的面向对象语言,但是我们仍然可以使用一些设计模式来提高代码的可读性和可维护性。今天,我将介绍一种常见的设计模式:修饰器模式。

Read more »
0%