Commit graph

19 commits

Author SHA1 Message Date
Henrik Böving
09de5cd70e
refactor: remove Lean.RBMap usages (#9260)
This PR removes uses of `Lean.RBMap` in Lean itself.

Furthermore some massaging of the import graph is done in order to avoid
having `Std.Data.TreeMap.AdditionalOperations` (which is quite
expensive) be the critical path for a large chunk of Lean. In particular
we can build `Lean.Meta.Simp` and `Lean.Meta.Grind` without it thanks to
these changes.

We did previously not conduct this change as `Std.TreeMap` was not
outperforming `Lean.RBMap` yet, however this has changed with the new
code generator.
2025-07-21 14:04:45 +00:00
Marc Huisinga
184dbae130
feat: reusable rpc refs (#8105)
This PR adds support for server-sided `RpcRef` reuse and fixes a bug
where trace nodes in the InfoView would close while the file was still
being processed.

The core of the trace node issue is that the server always serves new
RPC references in every single response to the client, which means that
the client is forced to reset its UI state.

In a previous attempt at fixing this (#8056), the server would memorize
the RPC-encoded JSON of interactive diagnostics (which includes RPC
references) and serve it for as long as it could reuse the snapshot
containing the diagnostics, so that RPC references are reused. The
problem with this was that the client then had multiple finalizers
registered for the same RPC reference (one for every reused RPC
reference that was served), and once the first reference was
garbage-collected, all other reused references would point into the
void.

This PR takes a different approach to resolve the issue: The meaning of
`$/lean/rpc/release` is relaxed from "Free the object pointed to by this
RPC reference" to "Decrement the RPC reference count of the object
pointed to by this RPC reference", and the server now maintains a
reference count to track how often a given `RpcRef` was served. Only
when every single served instance of the `RpcRef` has been released, the
object is freed. Additionally, the reuse mechanism is generalized from
being only supported for interactive diagnostics, to being supported for
any object using `WithRpcRef`. In order to make use of reusable RPC
references, downstream users still need to memorize the `WithRpcRef`
instances accordingly.

Closes #8053.

### Breaking changes

Since `WithRpcRef` is now capable of tracking its identity to decide
which `WithRpcRef` usage constitutes a reuse, the constructor of
`WithRpcRef` has been made `private` to discourage downstream users from
creating `WithRpcRef` instances with manually-set `id`s. Instead,
`WithRpcRef.mk` (which lives in `BaseIO`) is now the preferred way to
create `WithRpcRef` instances.
2025-06-03 12:35:12 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Wojciech Nawrocki
8d04ac171d
feat: bundle of widget improvements (#2964)
Implements RFC #2963.

Leftover tasks:
- [x] Provide companion PR to vscode-lean4 (leanprover/vscode-lean4#376)
- [x] Companion PR to std4 (leanprover/std4#467)
- [x] Companion PR to ProofWidgets4
(leanprover-community/ProofWidgets4#36)
- [X] Companion commit to mathlib4
(0f4660f655)
- [ ] ~~Update the manual chapter~~ (will do in a follow-up)
2023-12-21 06:24:33 +00:00
Mario Carneiro
85119ba9d1 chore: move Std.* data structures to Lean.* 2022-09-26 05:46:04 -07:00
Mario Carneiro
158e182b8b chore: move Bootstrap.Dynamic -> Init.Dynamic 2022-09-02 04:36:54 -07:00
Mario Carneiro
bf89c5a0f5 chore: move Std -> Bootstrap 2022-08-29 01:26:12 -07:00
Gabriel Ebner
e9545a426f refactor: RpcEncodable 2022-08-10 06:31:46 -07:00
Gabriel Ebner
37547ed887 feat: RpcEncodable derive handler 2022-08-10 06:31:46 -07:00
Gabriel Ebner
d36552848c chore: hide weird RpcEncoding behind Nonempty 2022-07-19 22:55:42 +02:00
Gabriel Ebner
b7bcb1616a chore: add inhabited instance for RpcEncoding
This allows us to define RpcEncodings as partial defs.
2022-07-19 22:55:42 +02:00
Leonardo de Moura
12e2a79170 chore: fix codebase after removing auto pure 2022-02-03 18:08:14 -08:00
Wojciech Nawrocki
2f5fbf3b13 feat: support multiple RPC sessions
Motivation: we may want to also use RPC in editor insets, or multiple
webviews in general.
2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
568cc3cf11 refactor: consistent naming of widget modules 2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
ce7f31a654 feat: keep-alive semantics for RPC sessions 2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
72df64e8fe chore: move RpcSession 2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
dae1a94d53 feat: misc server additions 2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
d2e23ff5cf fix: deriving RpcEncoding 2021-08-01 09:58:44 +02:00
Wojciech Nawrocki
1d57ffb4d7 refactor: shuffle classes to avoid dependency loops 2021-08-01 09:58:44 +02:00