sort worker-thread init functions in advance 38/19938/3
authorDave Barach <dave@barachs.net>
Mon, 3 Jun 2019 23:48:22 +0000 (19:48 -0400)
committerDamjan Marion <dmarion@me.com>
Tue, 4 Jun 2019 13:04:42 +0000 (13:04 +0000)
commitc602b384ac022f70690a3a7c711149f7cb63ad12
treecad51d5702502d35c714b3a003d000ffe7aae4db
parentc424de75e561b2197d29812b3900db58a06096d7
sort worker-thread init functions in advance

Otherwise, all N worker threads try to sort the list at the same time:
a good way to have a bad day.

This approach performs *far* better than maintaing order by adding a
spin-lock. By direct measurement w/ elog + g2: 11 threads execute the
per-thread init function list in 22us, vs. 50ms with a CLIB_PAUSE()
enabled spin-lock.

Change-Id: I1745f2a213c0561260139a60114dcb981e0c64e5
Signed-off-by: Dave Barach <dave@barachs.net>
src/vlib/init.c
src/vlib/init.h
src/vlib/main.c
src/vlib/threads.c
src/vlib/threads.h