[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGdX0WHK-EhGYHELxr-H_A+w1ZDWWhDpxsvB+=grMgFNpFsZ4g@mail.gmail.com>
Date: Sun, 30 Mar 2014 17:12:51 +0800
From: Jovi Zhangwei <jovi.zhangwei@...il.com>
To: Andi Kleen <andi@...stfloor.org>
Cc: Ingo Molnar <mingo@...hat.com>,
Steven Rostedt <rostedt@...dmis.org>,
LKML <linux-kernel@...r.kernel.org>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Frederic Weisbecker <fweisbec@...il.com>
Subject: Re: [PATCH v2 10/29] ktap: add string handling code(kernel/trace/ktap/kp_[str|mempool].[c|h])
On Sun, Mar 30, 2014 at 11:50 AM, Andi Kleen <andi@...stfloor.org> wrote:
>
> It's not clear to me why a kernel script language needs
> all that complicated string interning code.
>
> What kind of scripts would create as many strings that
> it would be worth it?
>
> I think it would be better to replace it with a really
> simple non interning dynamic string type.
>
Basically I think string interning is very useful in ktap, and
the implementation is not complicated(kp_str_new function
is very simple).
String interning will make string comparison and table index
extremely fast, just pointer equality, no strcmp. table index
is heavily used in these dynamic tracing tool ktap/stap/dtrace.
String interning make there don't need to copy whole string
each time when use string key in associative array(table)
(stap/dtrace need copy it), and don't need to compute
string hash every time when use string table key.
(Things became more easily if need to support multi-key
table, ktap don't need to pre-allocate string in table)
See test/benchmark/cmp_table.sh, that script compare
table operation between ktap with stap, the result is very
inspiring, ktap table operation overhead is quite lower than
stap, especially when use constant string key.
But I agree with you partly, because in some cases we don't
want/need to interning all string, for example:
trace xxx:yyy {
var str = cast("char *", arg1)
print(str)
}
In above case, arg1 is a long kernel string, and no table insert,
so definitely no need to interned, so we need to add
KTAP_TRAWSTR to represent these values.
The simplicity design of ktap make it very flexible to support
different kind of value type. :)
Thanks.
Jovi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists