yihong0618 / 2023

Another year
MIT License
204 stars 25 forks source link

TIL #11

Open yihong0618 opened 1 year ago

yihong0618 commented 1 year ago

TIL

til add ?

整合成一张 MD?

yihong0618 commented 1 year ago

git

同步其它项目

git remote add abc
git remote update
git merge abc/branch_a
yihong0618 commented 1 year ago

postgres

Why does the OID jump by 3 when creating tables?

When you create a table, it also creates two data types: tablename and _tablename. For example, for your table t1, you should have a t1 type and a _t1 type. Both have OIDs. On my cluster, your example gives me:

Why does my first tablespace in PostgreSQL always get the OID 16384?

123               OIDs beginning at 16384 are assigned from the OID generator              during normal multiuser operation.  (We force the generator up to*              16384 as soon as we are in normal operation.)
yihong0618 commented 1 year ago

Rust

why tokei is amazing fast

Well a lot of the performance came from replacing slice.iter().any(|i| line.starts_with(i)) with aho_corasick::AhoCorasick in a hot loop, as well adding per language memoization for things like AhoCorasick. I also added a heuristic where Tokei essentially splits your file from the start until there's "important" syntax that needs to be tracked across lines, and divides that work into two separate parallel tasks. This means if your file has simple enough syntax it can be counted entirely in parallel.

It's hard to list all or tell which made the most impact on performance, as I essentially tried to make every piece that could be concurrent, concurrent, and then repeatedly benchmarked to see if it actually improved it.