CacheControl / CacheControl/json-rules-engine
Slow performance while having large array of facts.
- Linguagem predominante
- JavaScript
- Estrelas
- 3.1k
- Forks
- 507
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
I have integrated json-rules-engine with a project I am working on and the performance seems much slower than I would expect. I'm using the package to do a simple lookup at another set of facts.
```
const lookupFacts = [
{ col1: '', col2: '', col3: ''},
{ col1: '', col2: '', col3: ''},
{ col1: '', col2: '', col3: ''}
]
const filterRule = {
conditions: {
all: [
{
path: "$.col1",
fact: "fact",
value: {
path: "$.col1",
fact: "lookup"
},
operator: "equal"
},
{
path: "$.col2",
fact: "data",
value: {
path: "$.col2",
fact: "lookup"
},
operator: "equal"
},
{
path: "$.col3",
fact: "data",
value: {
path: "$.col3",
fact: "lookup"
},
operator: "equal"
}
],
event: {
type: 'filter-event'
}
}
}
const engine = new require('json-rules-engine').Engine()
let filteredMatchs = await Promise.all(lookupFacts.map((lookup) => {
return engine.run({ lookup, data })
.then(({ events }) => events.length > 0 ? lookup : false)
.catch((err) => false)
}))
.then((values) => values.filter((value) => value))
```
In my case, the lookupfacts array seems to contain about 80000 entries and it takes around 30000 ms to complete. Whereas doing the same comparison using simple javascript code takes about 10-15 ms only.
I will only be not be having any dynamic data in the flow. Is there a way to improve performance?
Thanks
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Nenhum arquivo do repositório ou teste é especificado. Comece reproduzindo o benchmark fornecido em torno de Engine.run com 80.000 entradas e compare-o com a busca simples em JavaScript; o trabalho deve ser considerado concluído com uma melhoria de desempenho mensurada e aplicável ou com uma limitação claramente documentada.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- backend, performance
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 42/100