Skip to content

Commit

Permalink
Filter refactoring: dropped the recursion from the interpreter
Browse files Browse the repository at this point in the history
This is a major change of how the filters are interpreted. If everything
works how it should, it should not affect you unless you are hacking the
filters themselves.

Anyway, this change should make a huge improvement in the filter performance
as previous benchmarks showed that our major problem lies in the
recursion itself.

There are also some changes in nest and protocols, related mostly to
spreading const declarations throughout the whole BIRD and also to
refactored dynamic attribute definitions. The need of these came up
during the whole work and it is too difficult to split out these
not-so-related changes.
  • Loading branch information
marenamat committed Feb 20, 2019
1 parent 967b88d commit 4c553c5
Show file tree
Hide file tree
Showing 43 changed files with 1,676 additions and 1,246 deletions.
5 changes: 2 additions & 3 deletions conf/confbase.Y
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ CF_DECLS
struct f_tree *e;
struct f_trie *trie;
struct f_val v;
struct f_path_mask *h;
struct password_item *p;
struct rt_show_data *ra;
struct sym_show_data *sd;
Expand Down Expand Up @@ -124,14 +123,14 @@ conf: definition ;
definition:
DEFINE SYM '=' term ';' {
struct f_val *val = cfg_alloc(sizeof(struct f_val));
if (f_eval($4, cfg_mem, val) > F_RETURN) cf_error("Runtime error");
if (f_eval(f_postfixify($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error");
cf_define_symbol($2, SYM_CONSTANT | val->type, val);
}
;

expr:
NUM
| '(' term ')' { $$ = f_eval_int($2); }
| '(' term ')' { $$ = f_eval_int(f_postfixify($2)); }
| SYM {
if ($1->class != (SYM_CONSTANT | T_INT)) cf_error("Number expected");
$$ = SYM_VAL($1).i; }
Expand Down
2 changes: 1 addition & 1 deletion doc/bird.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -3982,7 +3982,7 @@ definitions, prefix definitions and DNS definitions:
RAdv protocol could be configured to change its behavior based on
availability of routes. When this option is used, the protocol waits in
suppressed state until a <it/trigger route/ (for the specified network)
is exported to the protocol, the protocol also returnsd to suppressed
is exported to the protocol, the protocol also returns to suppressed
state if the <it/trigger route/ disappears. Note that route export
depends on specified export filter, as usual. This option could be used,
e.g., for handling failover in multihoming scenarios.
Expand Down
16 changes: 14 additions & 2 deletions filter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ $(cf-local)

M4FLAGS_FILTERS=$(filter-out -s,$(M4FLAGS))

$(o)f-inst-interpret.c: $(s)interpret.m4 $(s)f-inst.c
$(o)f-inst-line-size.c: $(s)line-size.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@

$(o)filter.o: $(o)f-inst-interpret.c
$(o)f-inst-postfixify.c: $(s)postfixify.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@

$(o)f-inst-interpret.c: $(s)interpret.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@

$(o)f-inst-same.c: $(s)same.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@

$(o)f-inst-dump.c: $(s)dump.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@

$(o)filter.o: $(o)f-inst-interpret.c $(o)f-inst-line-size.c $(o)f-inst-postfixify.c $(o)f-inst-same.c $(o)f-inst-dump.c

tests_src := tree_test.c filter_test.c trie_test.c
tests_targets := $(tests_targets) $(tests-target-files)
Expand Down
Loading

0 comments on commit 4c553c5

Please sign in to comment.