Adjust the value in objects' insertion order array to the index - position.
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
Currently, we store an array of bytes at the end of the inline value array of objects to record the insertion order.
This is expensive as we need to compute not only the value to insert, but where to insert it. Here's the code:
PyDictValues *values = _PyObject_InlineValues(owner_o);
Py_ssize_t index = value_ptr - values->values;
_PyDictValues_AddToInsertionOrder(values, index);
_PyObject_InlineValues requires some lookup, as it depends on tp->basicsize
return (PyDictValues *)((char *)obj + tp->tp_basicsize);
but it is _PyDictValues_AddToInsertionOrder that is the slowest:
int size = values->size;
uint8_t *array = (uint8_t *)&values->values[values->capacity];
array[size] = (uint8_t)ix;
values->size = size+1;
If instead of storing the delta of the index and position, instead of just the index, for the majority of objects the insert order array will go from { 0, 1, 2, 3, 4, ... } to { 0, 0, 0, 0, 0, ... }
And if the delta is zero, we don't need to store anything.
PyDictValues *values = _PyObject_InlineValues(owner_o);
Py_ssize_t index = value_ptr - values->values;
Py_ssize_t delta = index - values->size;
if (delta != 0) {
/* This is the expensive part */
_PyDictValues_AddToInsertionOrder(values, delta);
}
values->size++;
In the JIT we can track the size of the inline values, and know when delta will be zero. Reducing the above code to
values->size = KNOWN_SIZE;
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece rastreando _PyObject_InlineValues e _PyDictValues_AddToInsertionOrder e, em seguida, examine o caminho de JIT descrito na issue para entender como o tamanho dos valores inline é rastreado. A tarefa estará concluída quando o armazenamento da ordem de inserção usar o comportamento de delta zero proposto sem alterar a ordem dos objetos, e o comportamento do runtime afetado continuar correto.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- c, python
- Domínio
- backend, performance
- Tipo de issue
- Refatoração
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100