On Sun, Mar 30, 2014 at 11:50 AM, Andi Kleen <a...@firstfloor.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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/