Improve performance of n-quads parsing#95
Improve performance of n-quads parsing#95michaeladler wants to merge 4 commits intopiprate:masterfrom
Conversation
Signed-off-by: Michael Adler <michael.adler@siemens.com>
cpu: AMD Ryzen 7 PRO 8840U BenchmarkParseNQuadsFrom-16 68916 16787 ns/op 9857 B/op 96 allocs/op BenchmarkLoadNQuads-16 3774422 320.8 ns/op Signed-off-by: Michael Adler <michael.adler@siemens.com>
Benchmarks show this is about 70-130 times faster. Signed-off-by: Michael Adler <michael.adler@siemens.com>
This is ~32% faster than the previous regex-based approach: cpu: AMD Ryzen 7 PRO 8840U BenchmarkParseNQuadsFrom-16 105422 11395 ns/op 11576 B/op 150 allocs/op BenchmarkLoadNQuads-16 3807912 315.1 ns/op Signed-off-by: Michael Adler <michael.adler@siemens.com>
d28b82f to
8de8357
Compare
|
@michaeladler, thank you for the PR. Will review asap. |
|
Hi @michaeladler, the proposed change makes sense but I'm a bit concerned it creates a circular dependency between github.com/cayleygraph/quad and github.com/piprate/json-gold through JSON-LD encoder/decoder. One alternative would be to bring in the necessary from into json-gold codebase (with attribution), given its static nature, but it's not ideal either. What are your thoughts? |
|
Hi @kazarena, I noticed that dependency as well but I don't think it's a problem. In Golang, cyclic dependencies happen at the package-level, not at the repository-level. json-gold: cayleygraph: Also: if it actually was a problem, we would get a compile error. I just ran the tests of |
This removes the use of regular expressions for parsing n-quads. As expected, this approach is significantly faster (over 30%) and results in cleaner code, thanks to the great work by the Cayley authors.
Motivation
Improve the performance of n-quads parsing.
Checks
make test