25 Commits

Author SHA1 Message Date
WGH
47be22e62a
Use std::shared_ptr for variable resolution
AnchoredSetVariable::resolve is called for every rule
(see RuleWithOperator::evaluate). The previous implementation allocated
a new copy of every variable, which quickly added up. In my tests,
AnchoredSetVariable::resolve function consumed 7.8% of run time.

AnchoredSetVariable (which is a multimap) values are never changed,
only added. This means it's safe to store them in std::shared_ptr,
and make resolve return shared_ptr pointing to the same object.

Other resolve implementation could also use this optimization by not
allocating new objects, however, they are not hot spots, so this
optimization was not implemented there.

In my benchmark, this raises performance from 117 requests per second to
131 RPS, and overhead is lowered from 7.8% to 2.4%.

As a bonus, replacing plain pointer with smart pointers make code
cleaner, since using smart pointers makes manual deletes no longer necessary.

Additionally, VariableOrigin is now stored in plain std::vector,
since it's wasteful to store structure containing just two integer
values using std::list<std::unique_ptr<T>>.
2020-08-10 10:35:07 -03:00
Felipe Zimmerle
357c140003
Changens copyright year 2020-01-31 10:32:37 -03:00
Felipe Zimmerle
86a5f471a9
Cosmetics: fixed static analysis issues. 2020-01-15 20:35:59 -03:00
Felipe Zimmerle
4e76c6adf0
Renames namespace Variables to variables 2019-03-06 15:53:20 -03:00
WGH
37cf60b8d2
Fix use of deleted Regex copy constructor in LMDB code
Bug introduced in ad28de4f. Fixes #2008.
2019-01-28 16:20:02 -03:00
Felipe Zimmerle
ee50fea266
Handling key exceptions on the variable itself
This is the first step towords to solve #1697
2018-09-24 16:16:30 -03:00
Felipe Zimmerle
e51297b436
Improvements on top of #1787 2018-06-12 15:43:08 -03:00
Ervin Hegedus
edb5993d5f
Fixed LMDB collection errors 2018-06-12 14:47:44 -03:00
Hegedüs Ervin
8d61a3df90
Fix LMDB compile error 2018-02-28 08:52:40 -03:00
Felipe Zimmerle
eeec7efb68
Renames collection::Variable to VariableValue 2018-02-20 13:40:01 -03:00
Felipe Zimmerle
36ab4b952f
Fix lmdb compilation issue 2017-03-06 15:02:00 -03:00
Felipe Zimmerle
e95efa05cc
Fix assorted memory and static analysis errors 2017-03-06 15:02:00 -03:00
Felipe Zimmerle
f2d149fc5f
Extends the direct access model to other collections 2017-03-06 15:02:00 -03:00
Felipe Zimmerle
59114dd598
Refactoring on the operators parsers (2/2)
This is the first step towards remove the memory leaks in the parser
2017-03-06 15:01:50 -03:00
Felipe Zimmerle
e181cb7e0a
Fix lmdb collections backend 2016-12-30 16:43:56 -03:00
Felipe Zimmerle
168fa22e19
Collections cleanup: removes resolveFirstCopy method 2016-12-28 19:56:27 -03:00
Felipe Zimmerle
507ec44cc2
Refactoring on `utils.cc' and adjacents
Completely removed the `utils.cc' by moving residual functions into
sub-classes of `utils/'
2016-11-03 20:26:27 -03:00
Felipe Zimmerle
a1a1c71d6b
Makes LMDB support optional 2016-09-13 09:51:03 -03:00
Felipe Zimmerle
4cf6c714ac
Cosmetics: Fix coding style 2016-07-12 21:59:17 -03:00
Felipe Zimmerle
4078677b7f
Cosmetic changes: applies changes suggested by static analysis 2016-07-12 00:46:12 -03:00
Felipe Zimmerle
3f38b56682
Renames testdb' to modsec-shared-collections' 2016-07-11 14:00:33 -03:00
Felipe Zimmerle
ad481be09e
lmdb backend: Adds support to select variables using regex 2016-07-11 11:00:06 -03:00
Felipe Zimmerle
833089eb70
Adds method resolveFirstCopy to collections
Using the copy whenever it is necessary to avoid memory leak.
2016-07-08 10:22:37 -03:00
Felipe Zimmerle
6e4226ee4d
Adds support to global collections shared among different process
There is a memory leak in the variable resolution that should be
contained by an internal change in the way that the variables
are resolved.
2016-07-07 23:03:47 -03:00
Felipe Zimmerle
5daf4873b5
build: Searching for LMDB during the configuration phase 2016-07-05 11:56:19 -03:00