perkeep / perkeep

Perkeep (née Camlistore) is your personal storage system for life: a way of storing, syncing, sharing, modelling and backing up content.
https://perkeep.org/
Apache License 2.0
6.51k stars 449 forks source link

pkg/search: remove string allocation in BloRefConstraint matcher #972

Open mpl opened 7 years ago

mpl commented 7 years ago

In pkg/search/query.go (https://camlistore-review.googlesource.com/c/camlistore/+/9866/12/pkg/search/query.go) , func (bc *BloRefConstraint) blobMatches

we have:

brs := br.String() , which allocates.

since blobMatches is (currently) run against all share claims when doing a request about claim shares, it could be expensive. And it gets even worse if we end up using BloRefConstraint for even more generic queries (e.g. that run blobMatches against all meta blobs).

We should find a way to either move that allocation up in the caller chain (i don't see how), or find a way to get the blob ref hash without allocating.

mpl commented 7 years ago

Relatedly, and as another requirement to close this issue, the allocation at:

https://camlistore-review.googlesource.com/c/camlistore/+/8326/13/pkg/search/query.go#1971

should go away as well.

mpl commented 7 years ago

https://camlistore-review.googlesource.com/c/camlistore/+/11566

mpl commented 6 years ago

https://camlistore-review.googlesource.com/c/camlistore/+/8326 updated with the no allocation improvement.

https://camlistore-review.googlesource.com/c/camlistore/+/9866 left todo.