• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/busybox


コミットメタ情報

リビジョン537fcc75f3203f08da3e562997e61e3b436eb97a (tree)
日時2020-04-14 08:42:51
作者Denys Vlasenko <vda.linux@goog...>
コミッターMauro Rossi

ログメッセージ

top: switch to malloced "globals".

This seems to be more efficient:

function old new delta
clearmems - 28 +28
display_process_list 1001 1018 +17
read_cpu_jiffy 171 177 +6
do_stats 194 198 +4
reset_term 20 23 +3
topmem_sort 63 65 +2
mult_lvl_cmp 44 45 +1
get_jiffy_counts 247 248 +1
display_topmem_process_list 549 546 -3
top_main 912 879 -33
handle_input 630 549 -81


(add/remove: 1/0 grow/shrink: 7/3 up/down: 62/-117) Total: -55 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

変更サマリ

差分

--- a/procps/top.c
+++ b/procps/top.c
@@ -142,6 +142,8 @@ typedef int (*cmp_funcp)(top_status_t *P, top_status_t *Q);
142142
143143 enum { SORT_DEPTH = 3 };
144144
145+/* Screens wider than this are unlikely */
146+enum { LINE_BUF_SIZE = 512 - 64 };
145147
146148 struct globals {
147149 top_status_t *top;
@@ -180,10 +182,9 @@ struct globals {
180182 #if ENABLE_FEATURE_USE_TERMIOS
181183 char kbd_input[KEYCODE_BUFFER_SIZE];
182184 #endif
183- char line_buf[80];
184-}; //FIX_ALIASING; - large code growth
185-enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) };
186-#define G (*(struct globals*)&bb_common_bufsiz1)
185+ char line_buf[LINE_BUF_SIZE];
186+};
187+#define G (*ptr_to_globals)
187188 #define top (G.top )
188189 #define ntop (G.ntop )
189190 #define sort_field (G.sort_field )
@@ -201,8 +202,7 @@ enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) };
201202 #define total_pcpu (G.total_pcpu )
202203 #define line_buf (G.line_buf )
203204 #define INIT_G() do { \
204- setup_common_bufsiz(); \
205- BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
205+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
206206 BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \
207207 } while (0)
208208