Try โ€‚โ€‰HackMD
tags: homework sysprog2017

2017q3 Homework1 (phonebook)

contributed by <Jetudie>


้กŒ็›ฎ๏ผš C02: phonebook

้–‹็™ผ็’ฐๅขƒ

ๅˆ—ๅ‡บCPU่ณ‡่จŠ
$ lscpu
(่ฆๆ›ด่ฉณ็ดฐไบ†่งฃไนŸๅฏไปฅ็”จ $ cat /proc/cpuinfo )

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 60
Model name:            Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
Stepping:              3
CPU MHz:               799.865
CPU max MHz:           3100.0000
CPU min MHz:           800.0000
BogoMIPS:              4988.06
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0-3

ๅˆ—ๅ‡บ็ณป็ตฑ็›ธ้—œ่ณ‡่จŠ
$ uname -a

Linux michael-Lenovo-IdeaPad-Z510 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

ๆธ…็ฉบ cache, ๆชข่ฆ–ไธ€ไธ‹่ณ‡ๆบ (ๅช้–‹ terminal ็š„ๆƒ…ๆณ)
$ echo 1 | sudo tee /proc/sys/vm/drop_caches
$ free

              total        used        free      shared  buff/cache   available
Mem:        8087436      281492     7619884       61484      186060     7543304
Swap:      10000380           0    10000380

ๆ•ˆ่ƒฝ

ไธ€้–‹ๅง‹็š„ๆ•ˆ่ƒฝ

$ make plot
original

$ make cache-test

 Performance counter stats for './phonebook_opt' (100 runs):

            35,407      cache-misses              #   46.277 % of all cache refs      ( +-  0.28% )
            76,511      cache-references                                              ( +-  0.37% )
        88,826,649      instructions              #    1.53  insn per cycle           ( +-  0.00% )
        58,161,375      cycles                                                        ( +-  0.19% )

       0.128115937 seconds time elapsed                                          ( +-  0.72% )

ๅƒ่€ƒ่ณ‡ๆ–™

  1. 2016 ๅนดๆ˜ฅๅญฃ็ณป็ตฑ่ชฒ็จ‹ Homework 1 ่งฃ่ชช

  2. cache ๅŽŸ็†ๅ’Œๅฏฆ้ฉ—

  3. ๆˆ‘็š„ๅทฅๅ…ท็ญ†่จ˜