goankur commented on PR #16771: URL: https://github.com/apache/lucene/pull/16771#issuecomment-5983873924
@Pulkitg64 Yes, and it matters most for large vectors. Today `FLOAT16` and `BYTE` align to `4 bytes`, so at `1024 dims` every other FP16 vector (2 KiB) and every fourth `BYTE` vector (1 KiB) crosses a page boundary: 1.5 and 1.25 pages per vector on average, against 1 when aligned. At `4096 dims` an FP16 vector is `8 KiB`, exactly two pages. Without alignment every vector starts at the same unaligned position inside a page, so every read touches 3 pages (12 KiB for 8 KiB of data). With 4096 alignment it touches exactly 2, with no read amplification at all. @CH-Abhinav That's also why I'd use 4096 for all encodings rather than 2048 for FP16 and 1024 for BYTE: 2048 alignment still leaves every 8 KiB vector spanning 3 pages when the data start lands mid-page. A vector avoids crossing a page whenever its size divides 4096 or is a multiple of it, and 4096 is the one alignment that covers all those sizes. The cost is under one page of padding per field per segment. Let me extend this PR to all three encodings. I won't have time to measure impact on FP16 vectors but please feel free to try this change and report your findings. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
