Commit Graph
11582 Commits
Author SHA1 Message Date
José Valim 472c4e1a24 Avoid crashes on diagnostics with tabs, closes #14073 2024-12-16 12:09:18 +01:00
José Valim 305d8e603c Do not convert fun() into (... -> any()) and vice-versa in typespecs 2024-12-15 15:18:52 +01:00
Jonatan Kłosko 1c7fc86e9c Make :source_path in docs chunk a charlist (#14071) 2024-12-13 16:57:54 +01:00
José Valim 617dc72759 Fix Range.new deprecation assertion 2024-12-13 10:14:47 +01:00
José Valim 4329a3c2f2 Address bootstrap 2024-12-13 10:01:18 +01:00
José Valim 8e8c9a7334 Wrap Range.new in Function.identity to avoid tail call optimization 2024-12-13 09:55:39 +01:00
Michał Łępicki 36c06c3a56 Fix JSON.decode/3 spec (#14068)
The error clause was missing the :error tuple wrapping
2024-12-13 09:52:42 +01:00
Mathias Polligkeit 048cc2ddb1 Further improve warning message for range with negative step (#14070) 2024-12-13 09:52:42 +01:00
Jean Klingler 6c866e8ab2 Fix type warnings in pop_in/1 (#14064) 2024-12-12 17:47:23 +09:00
José Valim 55eca5dff5 Implement JSON.Encoder for Calendar types (#14061) 2024-12-12 00:38:44 +01:00
Panagiotis Nezis 070a6d51bf Improve warning in Range.new/2 with negative step (#14062) 2024-12-12 00:38:40 +01:00
José Valim 9c28fb7a39 Improve JSON and Float docs 2024-12-11 21:08:20 +01:00
José Valim 3ca0bddd9d Fix encoding specs 2024-12-11 12:16:33 +01:00
José Valim e07a91594b Update deprecations 2024-12-11 12:02:01 +01:00
José Valim a78f1715dc Fix error message around single quote keywords 2024-12-10 19:30:39 +01:00
José Valim 66c5908619 Release v1.18.0-rc.0 2024-12-10 18:32:26 +01:00
José Valim 0e9b5ec070 Branch out v1.18 2024-12-10 15:01:43 +01:00
José Valim 71441623cc Update CHANGELOG and TODOs 2024-12-10 14:58:44 +01:00
José Valim aff4fdbb8e Update CHANGELOG 2024-12-10 12:49:30 +01:00
José Valim 793c114721 Add JSON encoding and decoding (#14021) 2024-12-10 12:14:30 +01:00
Leif Metcalf 3f01b31ce1 Mention syntax for updating multiple map keys (#14041) 2024-12-09 12:51:52 +01:00
José Valim 4328b090ae Add Duration.to_string (#14028) 2024-12-04 16:11:10 +01:00
Ray Chang 41832ba397 Use forward slash delimiters in Regex.split doc (#14031) 2024-12-04 00:43:10 +01:00
Theodor Fiedler d49937c7bd Simplify docs for Duration.to_iso8601/1 (#14030) 2024-12-03 20:04:57 +01:00
José Valim 768fa4963e Optimize inspection of binaries
We have used this code:

    data = Base.encode64(:crypto.strong_rand_bytes(2_000_000))

    Mix.Tasks.Profile.Tprof.profile(
      fn -> inspect(data, printable_limit: :infinity) end,
      type: :memory
    )

The first result reported this:

    Profile results of #PID<0.106.0>
    #                                    CALLS      %      WORDS PER CALL
    Total                             10666685 100.00 9268308211   868.90
    :code.ensure_loaded/1                    1   0.00          3     3.00
    Inspect.BitString.inspect/2              1   0.00          4     4.00
    Inspect.Algebra.group/2                  1   0.00          4     4.00
    Inspect.Algebra.format/2                 1   0.00          6     6.00
    Inspect.Algebra.format/3                 3   0.00          8     2.67
    :erlang.iolist_to_binary/1               2   0.00         11     5.50
    anonymous fn/2 in Kernel.struct/2        1   0.00         17    17.00
    Inspect.Opts.new/1                       1   0.00         17    17.00
    Code.Identifier.escape/5           2666669   0.06    5333344     2.00
    String.recur_printable?/2          2666669   0.29   26666778    10.00
    Code.Identifier.escape_map/1       2666668  28.72 2662035405   998.26
    Code.Identifier.escape_char/1      2666668  70.93 6574272614  2465.35

As you can see, most of the allocations were in escape_char,
which makes sense: it will be invoked a lot for raw binaries
and it allocated lists, instead of relying on binary optimizations.

We reimplemented Code.Identifier.escape/5 to rely on binary
optimizations which then yielded this:

    Profile results of #PID<0.112.0>
    #                                   CALLS      %    WORDS PER CALL
    Total                             5333350 100.00 26666864     5.00
    :code.ensure_loaded/1                   1   0.00        3     3.00
    Inspect.BitString.inspect/2             1   0.00        4     4.00
    Inspect.Algebra.group/2                 1   0.00        4     4.00
    Inspect.Algebra.format/2                1   0.00        6     6.00
    Code.Identifier.escape/4                1   0.00        8     8.00
    Code.Identifier.escape/5          2666669   0.00        8     0.00
    Inspect.Algebra.format/3                3   0.00        8     2.67
    :erlang.iolist_to_binary/1              2   0.00       11     5.50
    anonymous fn/2 in Kernel.struct/2       1   0.00       17    17.00
    Inspect.Opts.new/1                      1   0.00       17    17.00
    String.recur_printable?/2         2666669 100.00 26666778    10.00

Now the allocations are all on `recur_printable?/2`. By running this
command, we can find out why it is allocating so much:

    ERL_COMPILER_OPTIONS=bin_opt_info elixir lib/elixir/lib/string.ex

It happens that, due to a catch all, new binary contexts had to be
allocated. By addressing that, we now get:

    Profile results of #PID<0.119.0>
    #                                   CALLS      % WORDS PER CALL
    Total                             5333350 100.00    91     0.00
    :code.ensure_loaded/1                   1   3.30     3     3.00
    Inspect.BitString.inspect/2             1   4.40     4     4.00
    Inspect.Algebra.group/2                 1   4.40     4     4.00
    String.recur_printable?/2         2666669   5.49     5     0.00
    Inspect.Algebra.format/2                1   6.59     6     6.00
    Code.Identifier.escape/4                1   8.79     8     8.00
    Code.Identifier.escape/5          2666669   8.79     8     0.00
    Inspect.Algebra.format/3                3   8.79     8     2.67
    :erlang.iolist_to_binary/1              2  12.09    11     5.50
    anonymous fn/2 in Kernel.struct/2       1  18.68    17    17.00
    Inspect.Opts.new/1                      1  18.68    17    17.00

Which is several orders of magnitude fewer words. We basically
allocate the new escaped binary and a few extra bytes.

Closes #14029.
2024-12-03 18:34:59 +01:00
Eksperimental eadbd8bdf3 Fix typos (#14023)
The typos were detected by this app: https://pypi.org/project/typos/
running the following command

    typos --exclude "lib/elixir/unicode/" --exclude "man/" --exclude "typos"  --format brief
2024-12-01 16:59:24 +01:00
José Valim d97b29fa64 Improvements to comparison docs 2024-11-30 15:49:02 +01:00
José Valim b087a7501b Keep struct fields in calendar sigil for better pretty printing 2024-11-30 15:44:05 +01:00
maintenance-beam-app 13d3cc0a3f Update Unicode to version 16.0.0 (#14024)
This is an automated commit created by the Maintenance project
https://github.com/eksperimental/maintenance

Before merging, please read the release notes by visiting
<http://www.unicode.org/versions/Unicode16.0.0/>
and assess if additional changes are necessary in the code base.
2024-11-29 10:01:27 +01:00
José Valim 80993a465a Update docs generation config 2024-11-27 20:46:52 +01:00
José Valim 13f527aaa7 Use arity() consistently 2024-11-27 18:56:22 +01:00
José Valim e3bad83233 Move __deriving__ callback to the protocol 2024-11-27 18:38:48 +01:00
José Valim 1f98708649 Add @undefined_impl_description 2024-11-27 18:38:48 +01:00
José Valim 8eba863f8f Properly track stab inside container_cursor_to_quoted, closes #13826 2024-11-25 14:46:23 +01:00
José Valim a7264aa816 Update docs 2024-11-25 14:46:23 +01:00
Christopher Keele 0c0f53cd66 Correct small typo in PartitionSupervisor (#14014) 2024-11-23 23:35:40 +01:00
José Valim 32e0b9c54f Remove deprecated conditional in Date 2024-11-21 19:59:15 +01:00
Gary Rennie aa108ebb64 Fix docs for Process.monitor/2 (#14009)
Previously, the example contained 2 issues.

1. A syntax error on `receive` as there were no parens.
2. The example was incomplete, and would hang on the 2nd receive

This commit updates the example to reflect the original intent, by
sending 2 messages and getting a `:noproc` on the 2nd `receive`.
2024-11-21 14:50:49 +01:00
Dave Lucia 2f844fd77b Move value in protocol errors to its own line (#14003) 2024-11-21 10:00:11 +01:00
Tobias Pfeiffer 50619b1dbf Clarify the interplay of Stream and Enum (#14002) 2024-11-19 19:39:42 +01:00
José Valim bb028b951f Always consider Elixir modules on inference (#14000) 2024-11-19 13:40:16 +01:00
Jonatan Kłosko 8e1d0411ba Add token metadata to distinguish between :nil and nil (#13999) 2024-11-18 09:32:15 +01:00
Guillaume Duboc d7f8578742 Add map normalization cases (#13997) 2024-11-15 19:22:24 +01:00
José Valim 5c88118868 Fix typing violation reported by Dialyzer 2024-11-15 19:20:48 +01:00
Jonatan Kłosko 3b01b2a632 Add separate metadata entry for every block parens (#13996) 2024-11-15 13:55:22 +01:00
Theodor Fiedler 9c7604ccf2 Ignore microsecond precision when validating shift date duration (#13993) 2024-11-14 15:14:47 +01:00
José Valim a6ad2b8c03 Fix test which accidentally removed :throw 2024-11-14 12:28:13 +01:00
José Valim a7c8be77e6 Ensure one arity catch is always expanded to :throw 2024-11-14 11:16:38 +01:00
José Valim 52d6020787 Add functions to list of valid AST nodes
In theory we need to check if the function does not have
an environment but the goal of the check is not to be precise,
but rather to catch obvious mistakes.
2024-11-13 23:13:41 +01:00
José Valim bb9ddb3317 Mark negation inside refute as generated, closes #13992 2024-11-13 23:11:01 +01:00