Skip to content

Commit

Permalink
Revert "IL: optimize attribute cluster reading (#13821)"
Browse files Browse the repository at this point in the history
This reverts commit 179db4e.
  • Loading branch information
vzarytovskii committed Dec 5, 2022
1 parent db068a6 commit 1ea51f6
Showing 1 changed file with 13 additions and 38 deletions.
51 changes: 13 additions & 38 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,12 +1220,9 @@ type ISeekReadIndexedRowReader<'RowT, 'KeyT, 'T when 'RowT: struct> =
abstract CompareKey: 'KeyT -> int
abstract ConvertRow: byref<'RowT> -> 'T

let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowReader<'RowT, _, _>) =
let seekReadIndexedRowsByInterface numRows binaryChop (reader: ISeekReadIndexedRowReader<'RowT, _, _>) =
let mutable row = Unchecked.defaultof<'RowT>

let mutable startRid = -1
let mutable endRid = -1

if binaryChop then
let mutable low = 0
let mutable high = numRows + 1
Expand All @@ -1244,12 +1241,12 @@ let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowRead
elif c < 0 then high <- mid
else fin <- true

let res = ImmutableArray.CreateBuilder()

if high - low > 1 then
// now read off rows, forward and backwards
let mid = (low + high) / 2

startRid <- mid

// read backwards
let mutable fin = false
let mutable curr = mid - 1
Expand All @@ -1261,12 +1258,14 @@ let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowRead
reader.GetRow(curr, &row)

if reader.CompareKey(reader.GetKey(&row)) = 0 then
startRid <- curr
res.Add(reader.ConvertRow(&row))
else
fin <- true

curr <- curr - 1

res.Reverse()

// read forward
let mutable fin = false
let mutable curr = mid
Expand All @@ -1278,47 +1277,23 @@ let seekReadIndexedRowsRange numRows binaryChop (reader: ISeekReadIndexedRowRead
reader.GetRow(curr, &row)

if reader.CompareKey(reader.GetKey(&row)) = 0 then
endRid <- curr
res.Add(reader.ConvertRow(&row))
else
fin <- true

curr <- curr + 1

res.ToArray()
else
let mutable rid = 1
let res = ImmutableArray.CreateBuilder()

while rid <= numRows && startRid = -1 do
reader.GetRow(rid, &row)
for i = 1 to numRows do
reader.GetRow(i, &row)

if reader.CompareKey(reader.GetKey(&row)) = 0 then
startRid <- rid
endRid <- rid

rid <- rid + 1

let mutable fin = false

while rid <= numRows && not fin do
reader.GetRow(rid, &row)

if reader.CompareKey(reader.GetKey(&row)) = 0 then
endRid <- rid
else
fin <- true

startRid, endRid

let seekReadIndexedRowsByInterface numRows binaryChop (reader: ISeekReadIndexedRowReader<'RowT, _, _>) =
let startRid, endRid = seekReadIndexedRowsRange numRows binaryChop reader

if startRid <= 0 || endRid < startRid then
[||]
else
res.Add(reader.ConvertRow(&row))

Array.init (endRid - startRid + 1) (fun i ->
let mutable row = Unchecked.defaultof<'RowT>
reader.GetRow(startRid + i, &row)
reader.ConvertRow(&row))
res.ToArray()

[<Struct>]
type CustomAttributeRow =
Expand Down

0 comments on commit 1ea51f6

Please sign in to comment.