Merge pull request 'Fix madvise code' (#37) from master into release

Reviewed-on: https://git.marginalia.nu/marginalia/marginalia.nu/pulls/37
This commit is contained in:
Viktor Lofgren 2022-07-25 15:07:18 +02:00
commit 44e2bc18a6
2 changed files with 5 additions and 5 deletions

View File

@ -127,15 +127,15 @@ public class MultimapFileLong implements AutoCloseable, MultimapFileLongSlice {
var buff = mappedByteBuffers.get((int)(startLongs / bufferSize));
if ((int)(startLongs / bufferSize) != (int)((endLongs) / bufferSize)) {
logger.warn("Misaligned madvise, skipping");
logger.debug("Misaligned madvise, skipping");
return;
}
NativeIO.madviseRange(buff, advice, (startLongs % bufferSize) * WORD_SIZE, (int)(lengthLongs*WORD_SIZE));
}
public void pokeRange(long offset, int length) {
for (int i = 0; i < length; i += 4096/8) {
public void pokeRange(long offset, long length) {
for (long i = 0; i < length; i += 4096/8) {
get(offset + i);
}
}

View File

@ -4,9 +4,9 @@ import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.upserve.uppend.blobs.NativeIO;
import io.reactivex.rxjava3.schedulers.Schedulers;
import nu.marginalia.wmsa.edge.index.conversion.SearchIndexConverter;
import nu.marginalia.util.btree.BTreeReader;
import nu.marginalia.util.multimap.MultimapFileLong;
import nu.marginalia.wmsa.edge.index.conversion.SearchIndexConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -49,7 +49,7 @@ public class SearchIndex implements AutoCloseable {
urls.advice(NativeIO.Advice.Random);
words.forEachWordsOffset(offset -> {
var h = reader.getHeader(offset);
int length = (int) (h.dataOffsetLongs() - h.indexOffsetLongs());
long length = h.dataOffsetLongs() - h.indexOffsetLongs();
urls.adviceRange(NativeIO.Advice.Normal, offset, 512);