coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "jonikelee AT gmail.com" <jonikelee AT gmail.com>
- To: Gregory Malecha <gregory AT bedrocksystems.com>
- Cc: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Ltac2 Performance Question
- Date: Sun, 2 Aug 2020 01:12:25 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qv1-f49.google.com
- Ironport-phdr: 9a23:ms82AhEhAIfunCQ4LACkvJ1GYnF86YWxBRYc798ds5kLTJ7yrsSwAkXT6L1XgUPTWs2DsrQY0rSQ7PmrCDZIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfLJ/IA+0oAnMucUbhZVuIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1kyoMKSI3/3/LhcxxlKJboQyupxpjw47PfYqZMONycr7Bcd8GQGZMWNtaWS5cDYOmd4YBAeoPM/hFoYf+pVQOoxywCgawC+3g0TJImn370Lcm3+k7DQ3KwgotFM8OvnTOq9X1Mb8fXe63zKnPyzXDbvBW1in56IfWbB8suv6MXbdqfsrQzUkjDR/KjlKVqYDrIjiY0eYNs2+d7+phVuKglWonpB9vrTW0yccsj5PGhoMRylze6Sp5x4M1KMS+RUVmbtGqDIFeuDuGN4tqXMwiWWdotT44x7AauZC2YScHxpo6yxDQZfKKfZWF7x3/WeieJTp0mX1odayiixuz70Wuxe3yW8e73ltIoSRLktbCuHAR2hDO7MWMV/Vz/kCk2TmV1gDT7PlJIU81larHK54h36U/moAPvkTEGy/7nlj9gqyOdkg85OSk9+Dqbq/lq5KcLYN4lBzyP6A0lsGwBek0KhYCUmmH9eih0bDv4En0T6lPg/A5k6TVrIzWKMEVq6O2DQ9Y15sv5Aq7Ajql1dkXhmQILFxLeB+CgYjmJV7DLf/9APq7mVugjStkyvbbNbP7GJrNNGLMkLL5cLZ99UFczA0zwMha551OC7EBJOv/WlbvtNDFFxM5PQO5zuL9BNVy0YMeXm2PAquHP6/IrVCI4ecvL/GNZI8Tpjn9N+Ao6+DygXI9g1MQfqmk0YEJZHylGvlqOUqUbH70jtcEC2gKvw4+TOLwiF2FVD5ef3SyX6U65jE6C4KpE4PDSZ6zj7Ga0ye7G4dZZmFCClyWDXjocICEV+8WaC2OOs9hjiAEVb+5RoA90hGurRb2xKZjLurJ4SIVronj1dhw5+3Ljx4+7z10D8KH02GMVW54hG0IRyVllJx49GNnx1iEy7kwpvVcGNdT7rsdXR03OpnG3sRwBtzoXQnCZcaSVFujWZOtBjRnHfwrxNpbKUR6HdShgxTO0gKlBrYUk/qAA5l+uvbe2H7wJMt5xnvu26wojl1gScxKYz71zpVj/hTeUtaa236SkLynIOFFhHaUpTWziFGWtUQdazZeFKDMXHQRfEzT9I2r6UbLTrvoArMiYFIYlJyyb5BSY9istm1oAffuPNOEPjC0kma0QA+Wn/aCMNusdGIa0yHQTkMDllJLpCrUBU0FHi6k5lnmInl2D1u2OhHj9OB/rDWwSUpmlww=
I get similar times to Gregory. I tried an uconstr version of the cps
ltac1 build_it, and it runs about 25% faster than the constr version.
On Sat, 1 Aug 2020 23:56:47 -0400
Gregory Malecha <gregory AT bedrocksystems.com> wrote:
> The unsafe version of the tactic is included below, constructing the
> array is quite annoying, maybe there is notation that I missed?
> Certainly adding the [check] here is pretty expensive.
>
> I filed an issue here which contains the full text (also included
> below): https://github.com/coq/coq/issues/12785
>
> Returning to the earlier question, I get back a decent amount of
> performance in my original tactic by using [@conj p q l r] rather than
> [conj l r] in both the Ltac and the Ltac2 case.
>
> My latest figures show less performance loss than I originally
> measured (2x instead of 3x), there might have been too much jitter in
> my tests. The numbers below are averages of 10 fresh runs.
>
> (* Ltac2 implementation *)
> Ltac2 rec build2 p :=
> lazy_match! p with
> | True => constr:(I)
> | ?p /\ ?q =>
> let l := build2 p in
> let r := build2 q in
> constr:(@conj $p $q $l $r)
> end.
>
> (* Ltac2 (Unsafe) implementation *)
> Ltac2 rec build2_unsafe p :=
> lazy_match! p with
> | True => constr:(I)
> | ?p /\ ?q =>
> let l := build2_unsafe p in
> let r := build2_unsafe q in
> let ary := Array.make 4 p in
> let _ := Array.set ary 1 q in
> let _ := Array.set ary 2 l in
> let _ := Array.set ary 3 r in
> Unsafe.make (Unsafe.App 'conj ary)
> end.
>
> (* Ltac2 (Unsafe-Check) implementation *)
> Ltac2 rec build2_unsafe_check p :=
> lazy_match! p with
> | True => constr:(I)
> | ?p /\ ?q =>
> let l := build2_unsafe_check p in
> let r := build2_unsafe_check q in
> let ary := Array.make 4 p in
> let _ := Array.set ary 1 q in
> let _ := Array.set ary 2 l in
> let _ := Array.set ary 3 r in
> match Unsafe.check (Unsafe.make (Unsafe.App 'conj ary)) with
> | Val v => v
> | Err e => Control.throw e
> end
> end.
>
> (* Ltac implementation *)
> Ltac build_it p k :=
> lazymatch p with
> | True => k constr:(I)
> | ?p /\ ?q => build_it p ltac:(fun P => build_it q ltac:(fun Q => k
> constr:(@conj p q P Q)))
> end.
>
> Fixpoint build_goal (n : nat) : Prop :=
> match n with
> | 0 => True
> | S n => build_goal n /\ build_goal n
> end.
>
> Goal build_goal 10.
> simpl.
> Time Control.enter (fun () =>
> let g := Control.goal () in
> let pf := build2 g in
> exact $pf).
> (** *~0.2241s* *)
> Undo.
> Time Control.enter (fun () =>
> let g := Control.goal () in
> let pf := build2_unsafe g in
> exact $pf).
> (** *~0.1444s* *)
> Time Control.enter (fun () =>
> let g := Control.goal () in
> let pf := build2_unsafe_check g in
> exact $pf).
> (** *~0.2307s* *)
> Undo.
> Time repeat constructor.
> (** *~0.1658s* *)
> Undo.
> Time ltac1:(match goal with
> | |- ?G => build_it G ltac:(fun p => exact p)
> end).
> (** *~0.0939s* *)
> Qed.
>
>
- [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/01/2020
- Re: [Coq-Club] Ltac2 Performance Question, Jason Gross, 08/01/2020
- Re: [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/01/2020
- Re: [Coq-Club] Ltac2 Performance Question, Jason Gross, 08/01/2020
- Re: [Coq-Club] Ltac2 Performance Question, jonikelee AT gmail.com, 08/01/2020
- Re: [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Jason Gross, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Jason Gross, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, jonikelee AT gmail.com, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Jason Gross, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/02/2020
- Re: [Coq-Club] Ltac2 Performance Question, Gregory Malecha, 08/01/2020
- Re: [Coq-Club] Ltac2 Performance Question, Jason Gross, 08/01/2020
Archive powered by MHonArc 2.6.19+.