Cloudflare 開始在正式環境用 ARM server 了

在「Designing Edge Servers with Arm CPUs to Deliver 57% More Performance Per Watt」這邊 Cloudflare 提到了他們在正式環境用 ARM 架構了:

Our first Arm CPU was deployed in production earlier this month — July 2021.

記得測了很多年,其中遇到測試到一半看起來還不錯,但原廠商決定不繼續做的,直到後來又有廠商投入,到現在總算是有比較成熟的產品可以用。

隔壁棚 AWS 上的 ARM 伺服器用起來也是香到不行,還沒有用過的可以試看看,至少我這台 blog & wiki 也都是跑在上面。

另外文章裡有提到目前 x86 的效能,新一代的 AMD 大概只比前一代多了 39% 的每瓦效能,但如果是把 ARM 拿進來比的話會到 57%:

Our most recently deployed generation of edge servers, Gen X, used AMD Rome CPUs. Compared with that, the newest Arm based CPUs process an incredible 57% more Internet requests per watt. While AMD has a sequel, Milan (and which Cloudflare will also be deploying), it doesn’t achieve the same degree of energy efficiency that the Arm processor does — managing only 39% more requests per watt than Rome CPUs in our existing fleet.

開始推上 production 後應該會愈換愈快,而且代表 Cloudflare 也會開始針對 ARM 平台最佳化。

AMD 推出 FidelityFX Super Resolution

AMD 推出了功能上類似於 NvidiaDLSS 的技術,叫做 FidelityFX Super Resolution (FSR),並且 open source 出來:「AMD FidelityFX Super Resolution is Here」,另外可以看一下 GPUOpen 官方網站裡面的內容。

DLSS 的機制上可以這樣解釋,遊戲輸出 1080p,透過 machine learning 運算的方式將畫質提升到 2K 或是 4K,這樣比起遊戲直接要計算 2K 或是 4K 的輸出內容,運算量可能會比較少。

不過 DLSS 只能跑在 RTX 20xx 與 30xx 系列的顯卡上,以前的舊顯卡不支援。而先前 AMD 公佈 FSR 的時候,除了是宣示 AMD 也推出類似的技術外,另外一個賣點是 FSR 可以跑在 Nvidia 的顯卡上。

而這次的消息則是又多說明了 open source 的釋出部份,將在七月中放出來:「AMD FidelityFX Super Resolution is Here」。

The source code for FidelityFX Super Resolution 1.0 will be coming to GPUOpen in mid July!

目前有七個遊戲支援,後續會有更多遊戲加入...

挖 Ethereum 加熱房間...

大家都好像有過類似的想法,只是實際去做的不多 XDDD

有人把整個作法寫出來,挖 Ethereum 加熱房間:「How I heat my home by mining crypto currencies」。

從網站上的「About me」這邊看起來應該是住在奧地利?

I am a tech geek from Austin TX (USA), living on the country side in Austria and devote most of my time to my girlfriend, my company, my students and different projects.

不確定是哪個城市,先抓了首都維也納的溫度來看,看起來一到三月的平均氣溫都在個位數 (攝氏),可以理解暖氣應該是常備物品:

作者之前就先搞過一個可以一路接到 Grafana 的電錶,然後也有裝太陽能電板,但因為暖氣用電的關係而不夠用:

After building my own smart meter using 4$ in parts I started checking my electricity usage every day, which made me realize how expensive it is to heat your home. Especially since all heat and warm water in my low-energy house is made with electricity. I do have 4.8 kwp solar panels on my roof but in winter they don't cover too much for obvious reasons.

順便查了一下電價,在「Austria electricity prices」這頁可以看到奧地利的每一度要 USD$0.248:

而同一份資料上,台灣是 USD$0.101:

回到他的暖氣機,他是屬於中央空調大台機器的類型:

這種機器會恆溫輸出,所以是進風溫度愈低,就需要使用愈高的電能加熱。所以他想到的解法就是針對進風口預先用顯卡挖礦加熱 (四張 AMD 的 R9 390),這樣就可以降低暖氣機的電力消耗 (不過整體的消耗會提昇):

I had 4 older AMD R9 390 GPUs laying around (for the nVidia crowd that's basically on a level with a GTX 970) and I thought it could work.

後面就是改裝過程了,最後的結果雖然整體的電力使用量上升,但因為暖氣機的電力消耗降低,加上礦機挖到的 ETH 直接 cover 暖氣機的費用,反而讓暖氣機變免費了:

Success! I was able to lower my heat pump's electricity needs by ~50% and half of the costs are also paid for by the mining earnings

台灣的氣溫應該是用不太到 XDDD

用 SSD 的 I/O 暴力解

這篇「Achieving 11M IOPS & 66 GB/s IO on a Single ThreadRipper Workstation」用了 AMD 平台上的 PCI-e 4.0 硬幹出 4K 隨機讀取 11M IOPS 的速度,另外在大區塊讀取可以到 66GB/sec,後面這個速度應該是可以把 DDR4 記憶體頻寬吃滿...

硬體的部份,作者用了 8*1TB + 2*500GB 的 M.2 SSD 來建這組系統,然後接到卡上:

不過他好像沒提到這組機器的價錢 (雖然每個單品都查的到),大概算了一下 storage 的部份其實不怎麼貴,Samsung 980 Pro PCIe 4.0 M.2 SSD 的部份,1TB 每一條要 USD$160,500GB 要 USD$120,旁邊那些 CPU 與記憶體反而貴不少... 不過整台機器應該有機會在 USD$10000 搞定?

感覺拿來給剪片的人用很爽?至少在處理讀寫的時候應該是很順...

Let's Encrypt 升級資料庫伺服器 (AMD YES?)

Let's Encrypt 升級了 MariaDB 資料庫的伺服器 (跑 InnoDB),特地寫了一篇文章出來講:「The Next Gen Database Servers Powering Let's Encrypt」。

CPU 的部份從本來的 2x Intel Xeon E5-2650 (Total 24 cores / 48 threads) 換成了 2x AMD EPYC 7542 (Total 64 cores / 128 threads),這點在本來就是 CPU 滿載的情境下改善很大:

而本來的瓶頸一解決,也使得 API 的 latency 直接降下去:

回頭看一下架構,可以看到他們提到沒有使用分散式的資料庫,而是單台 database 硬撐,驗證了即使到了 Let's Encrypt 這種規模,以暴制暴還是很有效的:

We run the CA against a single database in order to minimize complexity. Minimizing complexity is good for security, reliability, and reducing maintenance burden. We have a number of replicas of the database active at any given time, and we direct some read operations to replica database servers to reduce load on the primary.

除了 CPU 暴力外,2TB RAM 與 24 顆 NVMe SSD 的搞法也是很讚的,擺明就是用記憶體拼 cache 的量,以及用大量的 NVMe SSD 疊 IOPS。

然後硬體還在成長,看起來暴力解應該會變成以後的基本答案了...

Amazon EC2 的新機種:R5b、D3 (D3en)、C6gn、M5zn、G4ad

Amazon EC2 除了昨天放出 Mac mini 消息打頭陣以外,其他機種的更新消息也陸陸續續公佈了:

比較有趣的 (對我而言),第一個是 ARM 架構的機器也推出 100Gbps 的 n 版本 c6gn,看起來很適合跑大流量的東西,馬上想到的就是自架的 memcached

另外是 m5zn,使用高頻率的 Intel Xeon,主打需要單核效率的程式,不過這是掛在 m 系列下,而不是 c 系列...

再來是使用 AMD GPU 的 g4ad,官方宣稱跟 NVIDIAg4dn 比起來,將會有 45% 的 C/P 值提昇,是個蘇媽跟老黃的對決:

However, when compared to G4dn the new G4ad instances enable up to 45% better price performance for graphics-intensive workloads, including the aforementioned game streaming, remote graphics workstations, and rendering scenarios. Compared to an equally-sized G4dn instance, G4ad instances offer up to 40% improvement in performance.

看起來 ARM 的消息沒有想像中的多...

AMD 的 Ryzen 5000 系列

這幾年 Intel 在 CPU 市場上被 AMD 打的不是很像樣,但因為單核效能高不少 (看起來是利用高時脈拼),勉強在遊戲市場上還能打 (程式最佳化問題 XD)。

但前幾天蘇媽家發表了新的 CPU,看起來這次 AMD 十一月要推出的 Ryzen 5000 系列 (Zen 3 架構) 會打破這個平衡:「AMD Ryzen 5000 and Zen 3 on Nov 5th: +19% IPC, Claims Best Gaming CPU」。

官方宣稱每個 clock 會有 19% 的效能成長,這表示在單顆核心上面的速度會增加:

The key element of the new product is the core design, with AMD’s latest Zen 3 microarchitecture, promising a 19% raw increase in performance-per-clock, well above recent generational improvements.

不過看了一下,同樣是 8c16t 的規格下,Zen 2 的 3700X 只要 65W,但同樣規格到 Zen 3 上就到了 5800X 的 105W,但一路上到 16c32t 的 5950X 也都還是 105W 就是了...

3700X 的頻率是 3.6/4.4 (Base/Turbo),對比的 5800X 則上拉一些到 3.8/4.7,而頂規 5850X 則是幹到了 3.4/4.9,這離 Intel 的 5.2 愈來愈近了。

另外官方分析的 19% 是這些累積出來的:

+2.7% Cache Prefetching
+3.3% Execution Engine
+1.3% Branch Predictor
+2.7% Micro-op Cache
+4.6% Front End
+4.6% Load/Store

對市場是個好消息,而且還是 AM4 腳位,現有主機板有推出韌體更新就有機會直接支援...

等真的有評測的時候再來看看各個吃 CPU 的遊戲的情況...

Mass Effect 的 3D 場景黑塊問題一路追到 Intel/AMD 的 SSE2 指令集...

Mass Effect 是個 2007 在 Xbox 上推出的遊戲,並且在 2008 推出 Windows 版,這個遊戲在 2011 年 AMD 推出的 CPU 上 (Bulldozer),某些場景會產生人物黑塊的 bug,社群有些猜測但一直都沒被證實,作者一路追出不少問題,並且給了一個還算乾淨的 workaround:「Fixing Mass Effect black blobs on modern AMD CPUs」,另外在 Hacker News 上有很精彩的討論:「Fixing Mass Effect black blobs on modern AMD CPUs (cookieplmonster.github.io)」。

這篇主要是看趣味的,裡面的狀況有點複雜。

社群有一些 workaround 可以避開這個問題,作者後來是從關閉 PSGP (Processor Specific Graphics Pipeline) 的方法找問題,然後發現在計算時會產生出 NaN 的問題,所以導致貼出來的圖就變成黑塊了...

一路追下去,發現遊戲本身好像沒什麼大問題,但跟 Direct3D 裡面的 D3DXMatrixInverse 有關,會依照 CPU 的支援度決定怎麼跑:

  • Disabling PSGP makes both Intel and AMD take a regular x86 code path.
  • Intel CPUs always take an intelsse2 code path.
  • AMD CPUs supporting 3DNow! take a amd_mmx_3dnow or amd3dnow_amdmmx code path, while CPUs without 3DNow take an intelsse2 code path.

會有這些邏輯是因為 AMD 在 2010 後決定放生 3DNow!,所以會需要這樣判斷。

接著寫了一隻小程式測試,用 memcmp() 判斷是不是一樣,結果發現 AMD 的 SSE2 跑出來的程式不被遊戲接受:(不一樣是正常的,因為這些指令本來就沒有要求完全正確,是可以接受誤差的)

接著就是翻資料,可以知道 XMMatrixInverse 算是接班人:

I figured that since we were to replace that matrix function anyway, I could try replacing it with XMMatrixInverse being a “modern” replacement for D3DXMatrixInverse. XMMatrixInverse also uses SSE2 instructions so it should be equally optimal to the D3DX function, but I was nearly sure it would break the same way.

所以就弄個一個 DLL,把本來呼叫 D3DXMatrixInverse 的部份用 XMMatrixInverse 改寫換掉:「SilentPatchME/source/D3DXMatrix.cpp」,這個方式算是乾淨的 workaround 掉,保持 API 相容性,以及該有的加速能力 (由 XMMatrixInverse 提供)。

Hacker News 上有討論到 Intel 與 AMD 這些指令在 SSE2 上的誤差值,都是在規格要求的範圍內:

Const-me 14 hours ago [–]

Here’s Intel versus AMD relative error of RCPPS instruction: http://const.me/tmp/vrcpps-errors-chart.png AMD is Ryzen 5 3600, Intel is Core i3 6157U.
Over the complete range of floats, AMD is more precise on average, 0.000078 versus 0.000095 relative error. However, Intel has 0.000300 maximum relative error, AMD 0.000315.

Both are well within the spec. The documentation says “maximum relative error for this approximation is less than 1.5*2^-12”, in human language that would be 3.6621E-4.

Source code that compares them by creating 16GB binary files with the complete range of floats: https://gist.github.com/Const-me/a6d36f70a3a77de00c61cf4f6c17c7ac

至於為什麼會生出 NaN 的原因,沒找出來還是有點可惜,不過這個解法還行,就是「新版的 library 既然沒問題,就大家也不要太計較舊版的問題」的概念...

Amazon EC2 推出 AMD 版本的 C5a 主機

前幾天 AWS 宣佈了使用 AMD CPU 的 c5a 主機:「New – Amazon EC2 C5a Instances Powered By 2nd Gen AMD EPYC™ Processors」。

定價上與其他 AWS 上 AMD 的機器都類似 (m5ar5a 以及 t3a),大約都低 10% 左右:

Today, I am excited to announce the general availability of compute-optimized C5a instances featuring 2nd Gen AMD EPYC™ processors, running at frequencies up to 3.3 GHz. C5a instances are variants of Amazon EC2’s compute-optimized (C5) instance family and provide high performance processing at 10% lower cost over comparable instances.

以這兩年 AMD 在 CPU 這塊碾壓 Intel 的情況來說 (AMD YES!),目前 AMD CPU 上唯一的缺點應該是單核的時脈比較低,這在捉機上的領域裡面來說,遇到一些沒有做好多核最佳化的遊戲時 Intel 的表現會比較好,其他的情況其實都可以看出 AMD 幹爆 Intel。

如果你在 AWS 上跑的應用程式也有類似需要吃單核效能,無法充分使用多核環境時,還是可以回頭看一下 c5 系列,頻率會高一些:

C5 and C5d instances feature either the 1st or 2nd generation Intel Xeon Platinum 8000 series processor (Skylake-SP or Cascade Lake) with a sustained all core Turbo CPU clock speed of up to 3.6 GHz. The new C5 and C5d 12xlarge, 24xlarge, and metal instance sizes feature the 2nd generation Intel Xeon Scalable Processors (Cascade Lake) with a sustained all-core Turbo CPU frequency of 3.6GHz.

說到這個,Linus 前陣子在發表 5.7-rc7 的時候也說換了 AMD 的 3970x,整個處理 kernel 編譯的速度是用倍數在改善:「Linux 5.7-rc7」:

In fact, the biggest excitement this week for me was just that I upgraded my main machine, and for the first time in about 15 years, my desktop isn't Intel-based. No, I didn't switch to ARM yet, but I'm now rocking an AMD Threadripper 3970x. My 'allmodconfig' test builds are now three times faster than they used to be, which doesn't matter so much right now during the calming down period, but I will most definitely notice the upgrade during the next merge window.

回到 AWS 這邊... 目前有提供的區域來說,歐美比較大的區域都在首發清單,台灣這邊比較常用的東京還沒有看到,不過公司在用的新加坡上了:

You can launch C5a instances today in eight sizes in the US East (N. Virginia), US East (Ohio), US West (Oregon), Europe (Ireland), Europe (Frankfurt), Asia Pacific (Sydney), and Asia Pacific (Singapore) Regions in On-Demand, Spot, and Reserved Instance or as part of a Savings Plan.

如果沒有什麼特別成本壓力的人,可以等一陣子看看有沒有其他人丟效能測試出來,看看 CPU 的計算能力是不是可以無痛換過去... (這邊是相較於 ARM 那邊)

AMD 平台的前面板與 USB...

Telegram 上看到這篇在講在 AMD 平台上遇到 USB 相容性的問題:

看了敘述與裡面連結提到的「Xperia XA2: Stuck on “Sending 'boot.img'”」與「Fastboot is getting stuck while trying to flash CWM onto Nexus 4」後,我就馬上想到我在換成 AMD 的平台後,遇到了一個感覺好像應該是有關的問題...

我遇到的問題是 YubiKey 在主機的前面板的四個 USB 接口都不會動 (抓的到,但是 browser 需要認證時 YubiKey 不會閃爍請使用者確認),而接到 USB 2.0 Hub 上面也不會動 (這邊的 Hub 是接到後面 USB 3.0 的孔),只有直接接到後面板的 USB 3.0 會動,所以我後來就買了一條 USB 3.0 的延長線,從後面的 USB 3.0 孔拉到桌上用...

昨天看到文章,為了確認這個情況,就到 PChome 24h 上找了一顆 USB 3.0 Hub,今天收到後接上 PC 測試,發現 YubiKey 就順利在登入時閃爍了,看起來之後在 AMD 平台上接 USB 的時候要注意一下,有狀況的時候要多測幾種不同的接法...