Skip to content

Instantly share code, notes, and snippets.

View wdv4758h's full-sized avatar

Chiu-Hsiang Hsu wdv4758h

View GitHub Profile
@wdv4758h
wdv4758h / latency.txt
Created April 16, 2023 06:27 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@wdv4758h
wdv4758h / custom_game_engines_small_study.md
Created June 23, 2022 09:52 — forked from raysan5/custom_game_engines_small_study.md
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like Unreal or Unity for their games (or that's what lot of people think) because d

@wdv4758h
wdv4758h / bind10.md
Created July 6, 2014 11:00
BIND10 / Bundy
@wdv4758h
wdv4758h / Makefile
Created June 26, 2018 16:03
Just a sample
taskA:
@echo "this is task A"
@sleep 1
@echo "end task A"
taskB: taskA
@echo "this is task B"
@sleep 3
@echo "end task B"
@wdv4758h
wdv4758h / web_storage.md
Last active May 14, 2018 04:24
HTML5 Web Storage (Local Storage, Session Storage)
  • Web Storage 是一種可讓網頁將資料儲存於本地端的技術,其作用如同 cookie,但空間更大
  • 主要有兩種
    • local storage (類似 persistent cookies)
    • session storage (類似 session cookies)
  • 原本是 HTML5 規格的一部份,後來單獨劃為一個規格
  • Web Storage 純粹運作於 client side

Web Storage 和 Cookies 不同處

@wdv4758h
wdv4758h / WhatIsStrictAliasingAndWhyDoWeCare.md
Created April 5, 2018 06:59 — forked from shafik/WhatIsStrictAliasingAndWhyDoWeCare.md
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@wdv4758h
wdv4758h / cpuinfo.py
Last active November 10, 2017 07:46
Add AVX/AVX2 detect
#!/usr/bin/env python3
###################################################################
# cpuinfo - Get information about CPU
#
# License: BSD
# Author: Pearu Peterson <pearu@cens.ioc.ee>
#
# See LICENSES/cpuinfo.txt for details about copyright and
# rights to use.

Looking into the Future

futures-rs is the library which will hopefully become a shared foundation for everything async in Rust. However it's already become renowned for having a steep learning curve, even for experienced Rustaceans.

I think one of the best ways to get comfortable with using a library is to look at how it works internally: often API design can seem bizarre or impenetrable and it's only when you put yourself in the shoes of the library author that you can really understand why it was designed that way.

In this post I'll try to put down on "paper" my understanding of how futures work and I'll aim to do it in a visual way. I'm going to assume you're already somewhat familiar with Rust and why futures are a useful tool to have at one's disposal.

For most of this post I'll be talking about how things work today (as of September 2017). At the end I'll touch on what's being proposed next and also make a case for some of the changes I'd like to see.

If you're interested in learning more ab