jpountz commented on code in PR #13636: URL: https://github.com/apache/lucene/pull/13636#discussion_r1708959969
########## lucene/core/src/java/org/apache/lucene/internal/vectorization/DefaultPostingDecodingUtil.java: ########## @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.internal.vectorization; + +import java.io.IOException; +import org.apache.lucene.store.IndexInput; + +final class DefaultPostingDecodingUtil extends PostingDecodingUtil { + + protected final IndexInput in; + + public DefaultPostingDecodingUtil(IndexInput in) { + this.in = in; + } + + @Override + public void splitLongs(int count, long[] b, int bShift, long bMask, long[] c, long cMask) + throws IOException { + assert count <= 64; + in.readLongs(c, 0, count); + // The below loop is auto-vectorized + for (int i = 0; i < count; ++i) { + b[i] = (c[i] >>> bShift) & bMask; + c[i] &= cMask; Review Comment: I just ran the benchmark without enabling the vector module so that results are comparable with the current implementation in `main`: ``` Benchmark (bpv) Mode Cnt Score Error Units PostingIndexInputBenchmark.decode 5 thrpt 15 33.918 ± 0.422 ops/us PostingIndexInputBenchmark.decode 6 thrpt 15 33.804 ± 0.525 ops/us PostingIndexInputBenchmark.decode 7 thrpt 15 32.172 ± 0.653 ops/us PostingIndexInputBenchmark.decode 8 thrpt 15 36.298 ± 0.781 ops/us PostingIndexInputBenchmark.decode 9 thrpt 15 27.755 ± 0.504 ops/us PostingIndexInputBenchmark.decode 10 thrpt 15 29.801 ± 0.598 ops/us PostingIndexInputBenchmark.decodeAndPrefixSum 5 thrpt 15 17.911 ± 0.373 ops/us PostingIndexInputBenchmark.decodeAndPrefixSum 6 thrpt 15 17.775 ± 0.997 ops/us PostingIndexInputBenchmark.decodeAndPrefixSum 7 thrpt 15 15.688 ± 1.106 ops/us PostingIndexInputBenchmark.decodeAndPrefixSum 8 thrpt 15 17.817 ± 1.342 ops/us PostingIndexInputBenchmark.decodeAndPrefixSum 9 thrpt 15 15.794 ± 0.461 ops/us PostingIndexInputBenchmark.decodeAndPrefixSum 10 thrpt 15 15.291 ± 1.781 ops/us ``` There seems to be a performance hit in all cases, with a higher performance hit for bits per value that do not need to apply the mask (5, 8, 9 and 10). So it looks like you are right, I will look into it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org