diff --git a/src-jl/CorvusJsonSchema/Project.toml b/src-jl/CorvusJsonSchema/Project.toml index 3deae813a42..04b16e93c9d 100644 --- a/src-jl/CorvusJsonSchema/Project.toml +++ b/src-jl/CorvusJsonSchema/Project.toml @@ -1,7 +1,7 @@ name = "CorvusJsonSchema" uuid = "7b662be2-3602-4bf9-b859-13b2e88448f1" authors = ["Endjin Limited"] -version = "0.1.1" +version = "0.1.2" [compat] julia = "1.10" diff --git a/src-jl/CorvusJsonSchema/VERSIONHISTORY.md b/src-jl/CorvusJsonSchema/VERSIONHISTORY.md index 5d5384b5d13..158f95d34d5 100644 --- a/src-jl/CorvusJsonSchema/VERSIONHISTORY.md +++ b/src-jl/CorvusJsonSchema/VERSIONHISTORY.md @@ -2,6 +2,14 @@ The version history of `CorvusJsonSchema`, the Julia port of the Corvus.Text.Json V5 runtime evaluator. It is versioned independently of the Corvus NuGet packages, whose history is in the repository's [VERSIONHISTORY.md](../../VERSIONHISTORY.md). +## V0.1.2 + +V0.1.2 fixes the installation of the package on a slow machine. There are no API changes. Version 0.1.1 is affected, and 0.1.0 is not. + +### Bug fixes + +- **Precompilation on a slow machine.** Julia runs a workload while it writes the package's image, so that a process starts with the code compiled, and an error in it fails the installation. The workload of 0.1.1 sets a limit of 10 ms on a match, and expects two of its matches to answer within it: one against a string of a few characters, and the search of a string of 20,000 characters. Where they take longer, such as in a build of an image for another processor under emulation, the match reached its limit, the `PatternMatchError` was not caught, and `Pkg.add` or `Pkg.precompile` failed with "The following 1 package failed to precompile". Each timed match of the workload now ends at the limit without an error. No answer of the package changes. + ## V0.1.1 V0.1.1 gives patterns the answers of ECMA-262 on every file of the [ECMA-262 regular expression test data](https://github.com/corvus-dotnet/ecma262-regex-test-data), bounds what a pattern and a format can cost, and carries the notice of the Unicode data its tables are derived from. The functions that were there are unchanged. There is one new option and there are two new errors. Version 0.1.0 is affected by the bugs. diff --git a/src-jl/CorvusJsonSchema/src/precompile.jl b/src-jl/CorvusJsonSchema/src/precompile.jl index 8a9770b0cd3..e82e6dd249a 100644 --- a/src-jl/CorvusJsonSchema/src/precompile.jl +++ b/src-jl/CorvusJsonSchema/src/precompile.jl @@ -6,7 +6,7 @@ # The workload runs only during precompilation. It leaves nothing behind but compiled code: the caches it filled # are emptied, since a compiled pattern of the engine holds memory of the process that made it. -function precompile_workload() +function precompile_workload(; pattern_match_limit::Float64=0.01) large = join(["\"p$i\": $i" for i in 0:79], ",") cases = Tuple{String,NamedTuple,Vector{String}}[ ("""{ @@ -188,17 +188,21 @@ function precompile_workload() end isvalid(engine, "[1, 2") # A match that uses the steps it starts with, one that is timed and given up at its limit, the search of a long - # string in parts, and a pattern over a limit of size. + # string in parts, and a pattern over a limit of size. Each is timed, and whether one answers within the limit + # depends on the machine (under emulation the search of the long string takes longer than 10 ms), so each may end + # at the limit: an error here would fail the installation of the package. slow = compile_schema("""{"pattern": "^(?:a|a)+\$", "patternProperties": {"fo+|ba+r": true}}"""; - pattern_match_limit=0.01) - isvalid(slow, "\"" * "a"^12 * "b\"") - try - isvalid(slow, "\"" * "a"^40 * "b\"") - catch err - err isa PatternMatchError || rethrow() - sprint(showerror, err) - end - isvalid(slow, "{\"" * "x"^20_000 * "\": 1}") + pattern_match_limit) + timed(f) = + try + f() + catch err + err isa PatternMatchError || rethrow() + sprint(showerror, err) + end + timed(() -> isvalid(slow, "\"" * "a"^12 * "b\"")) + timed(() -> isvalid(slow, "\"" * "a"^40 * "b\"")) + timed(() -> isvalid(slow, "{\"" * "x"^20_000 * "\": 1}")) try compile_schema("{\"pattern\": \"" * "("^300 * "\"}") catch err diff --git a/src-jl/CorvusJsonSchema/test/precompile.jl b/src-jl/CorvusJsonSchema/test/precompile.jl new file mode 100644 index 00000000000..f8bf40c6712 --- /dev/null +++ b/src-jl/CorvusJsonSchema/test/precompile.jl @@ -0,0 +1,11 @@ +# The precompile workload runs while a package image is written, on whatever machine installs the package, and an +# error in it fails the installation. Its timed matches must not depend on how fast that machine is: 0.1.1 failed to +# precompile under emulation, where a match it expected to answer reached the workload's limit of 10 ms. + +@testset "the precompile workload does not depend on the speed of the machine" begin + # A limit that every timed match of the workload reaches at its first reading of the clock. + @test CorvusJsonSchema.precompile_workload(pattern_match_limit=1e-9) === nothing + @test CorvusJsonSchema.precompile_workload() === nothing + # The workload leaves the package as it found it. + @test isvalid(compile_schema("""{"patternProperties": {"fo+|ba+r": {"type": "integer"}}}"""), """{"foo": 1}""") +end diff --git a/src-jl/CorvusJsonSchema/test/runtests.jl b/src-jl/CorvusJsonSchema/test/runtests.jl index b0610c425ca..877c39751c9 100644 --- a/src-jl/CorvusJsonSchema/test/runtests.jl +++ b/src-jl/CorvusJsonSchema/test/runtests.jl @@ -15,4 +15,5 @@ include("allocations.jl") include("stability.jl") include("differential.jl") include("docs.jl") +include("precompile.jl") include("ecmaregex/runtests.jl")