Skip to content

Commit aa5d254

Browse files
committed
Drop unrolled annotation as its not affecting performance
1 parent 99fa5b3 commit aa5d254

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

bench/bench.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ let _ =
225225
List.init 1000 ~f:(fun i -> i+1, i * i+1) |> make_tests "map<int64,int64>" (module Protoc.Map) (module Plugin.Map);
226226

227227
(* random_list ~len:100 ~f:(fun () -> Plugin.Enum_list.Enum.ED) () |> make_tests (module Protoc.Enum_list) (module Plugin.Enum_list); *)
228-
] @ make_int_tests (0xFFFF_FFFFL) @ make_int_tests (0xFFFF_FFFF_FFFF_FFFFL)
228+
]
229+
@ make_int_tests (0x1L)
230+
@ make_int_tests (0xFFFFL)
231+
@ make_int_tests (0xFFFF_FFFFL)
232+
@ make_int_tests (0xFFFF_FFFF_FFFF_FFFFL)
229233
in
230234
printf "| Name | plugin | protoc | ratio |\n";
231235
printf "| -- | -- | -- | -- |\n";

src/ocaml_protoc_plugin/reader.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ let[@inline] read_byte t =
3636
v
3737
| false -> Result.raise `Premature_end_of_input
3838

39+
(* TODO: Speedup by inlining read_byte by copying out offset and end_offset out of the t structure so the inner loop does not have any side-effects. The copy back the offset to t once done. *)
40+
3941
let read_varint t =
4042
let open Infix.Int64 in
4143
let rec inner acc bit =
@@ -46,7 +48,7 @@ let read_varint t =
4648
inner acc (Int.add bit 7)
4749
| false -> acc
4850
in
49-
(inner[@unrolled 10]) 0L 0
51+
inner 0L 0
5052

5153
let read_varint_unboxed t = read_varint t |> Int64.to_int
5254

src/ocaml_protoc_plugin/writer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let write_varint buffer ~offset v =
3838
Bytes.unsafe_set buffer offset ((v land 0x7fL) lor 0b1000_0000L |> Int64.to_int |> Char.unsafe_chr);
3939
inner ~offset:next_offset rem
4040
in
41-
(inner[@unrolled 10]) ~offset v
41+
inner ~offset v
4242

4343
let write_varint_unboxed buffer ~offset v = write_varint buffer ~offset (Int64.of_int v)
4444

0 commit comments

Comments
 (0)