[
https://issues.apache.org/jira/browse/LUCENE-9652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17256921#comment-17256921
]
Adrien Grand commented on LUCENE-9652:
--------------------------------------
bq. I think we should only support little-endian floats from the beginning
here. We're planning to move towards switching the whole IndexInput to that
endianness, right?
+1
bq. but I think if we're still unreleased and in an experimental class that
should be OK?
Since it's unreleased, we can change the file format of VectorFormat however we
want without adding backward-compatibility logic indeed. In my opinion, the
experimental flag is more about the API than the file format compatibility.
Once a file format is released, we need to maintain backward compatibility,
regardless of whether it's experimental or not.
bq. Also, we don't need a corresponding DataOutput.writeFloats to support the
current usage for vectors, since there we rely on VectorValues to do the
conversion, so I don't plan to implement that.
+1
Ultimately, it would be nice if we could avoid copying the data entirely by
just interpreting the bytes from the DataInput as a float[] array. We can
technically do it today by making the dot product helper take a DataInput and
read floats one by one, but this has the downside of disabling
auto-vectorization of the dot product. I started looking at the vector API that
is new in JDK 16 recently, and it looks like it could help remove this copy
since it allows [creating a FloatVector from a
ByteBuffer|https://download.java.net/java/early_access/jdk17/docs/api/jdk.incubator.vector/jdk/incubator/vector/FloatVector.html#fromByteBuffer(jdk.incubator.vector.VectorSpecies,java.nio.ByteBuffer,int,java.nio.ByteOrder)].
> DataInput.readFloats to be used by Lucene90VectorReader
> -------------------------------------------------------
>
> Key: LUCENE-9652
> URL: https://issues.apache.org/jira/browse/LUCENE-9652
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Michael Sokolov
> Priority: Major
>
> Benchmarking shows a substantial performance gain can be realized by avoiding
> the additional memory copy we must do today when converting from {{byte[]}}
> read using {{IndexInput}} into {{float[]}} returned by
> {{Lucene90VectorReader}}. We have a model for how to handle the various
> alignments, and buffer underflow when a value spans buffers, in
> {{readLELongs}}.
> I think we should only support little-endian floats from the beginning here.
> We're planning to move towards switching the whole IndexInput to that
> endianness, right?
> Lucene90VectorWriter relies on {{VectorValues.binaryValue()}} to return bytes
> in the format expected by the reader, and its javadocs don't currently
> specify their endianness. In fact the order has been the default supplied by
> {{ByteBuffer.allocate(int)}}, which I now realize is big-endian, so this
> issue also proposes to change the index format. That would mean a
> backwards-incompatible index change, but I think if we're still unreleased
> and in an experimental class that should be OK?
> Also, we don't need a corresponding {{DataOutput.writeFloats}} to support the
> current usage for vectors, since there we rely on {{VectorValues}} to do the
> conversion, so I don't plan to implement that.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]