jcoglan opened a new pull request, #5869:
URL: https://github.com/apache/couchdb/pull/5869

   ## Overview
   
   While working on `mango_selector:match()` to implement detailed match 
failure information, I noticed that every time a non-operator field is 
evaluated, we call `mango_doc:get_field()`, which calls 
`mango_util:parse_field()` if its input is a binary. We can avoid re-parsing 
fields so often by changing `norm_fields` so that it normalizes to the parsed 
form `[<<"a">>, <<"b">>]` instead of `<<"a.b">>`.
   
   The changes have made the benchmarks I added about 30-40% faster. (I wasn't 
sure where benchmarks like this should live, if anywhere... they're mostly here 
for me to check the effect and I'm happy to move or remove them before merging.)
   
   In the first commit here I make this change and then change all the other 
logic that interacts with selectors to also use this form. This ended up having 
a bigger blast radius than I would have liked, so I undid most of it and 
changed the `mango_selector` functions and a couple others so they hide how 
normalized selector fields actually look from other callers. There's only a 
couple of places where these normalized selectors need to be turned back into 
valid JSON, and the `mango_util:join_keys()` function turns the array keys back 
into binaries as needed.
   
   There are a couple of places in the logic for choosing indexes for queries 
where we now have to parse fields to match the form they appear in in 
selectors, but I figure doing this once per query during index selection is 
better than doing it once per selector-field evaluation during index updates or 
filtering.
   
   I assume the latter commit is the state we'd actually want to keep so I'm 
happy to squash all the other edits away.
   
   ## Related Issues or Pull Requests
   
   - https://github.com/apache/couchdb/pull/5792
   - https://github.com/apache/couchdb/pull/5839
   
   ## Checklist
   
   - [ ] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in 
`rel/overlay/etc/default.ini`
   - [ ] Documentation changes were made in the `src/docs` folder
   - [ ] Documentation changes were backported (separated PR) to affected 
branches
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to