Commit Graph

51 Commits (297bf4a506db4c5db082ce568ed4b18075aa886a)

Author SHA1 Message Date
Mike Gerwitz e20076235e _table-row_: Performance fix: place table in const/text() instead of const/@values
This is an interesting one.

For some context: TAME uses `csvm` files to provide syntactic sugar for
large tables of values ("rate tables", as they're often called, since they
contain insurance rates and other data).  This gets desugared into a `csv`
which in turn is compiled via `csv2xml` into a package.  That package uses
the `_table-*_` templates to define a table, which is represented as a
matrix using `const/@values`.

Here's an example of a generated table in a package:

```
  <t:create-table name="foo">
        <t:table-rows data="
          1,2,3;
          4,5,6;" />
  </t:create-table>
```

Some of the tables are quite large, generating tens of MiB of data in
`@data`.  This in itself isn't a problem.  But when Saxon parses the `@data`
attribute, it normalizes the whitespace, as mandated by the XML spec, and
removes the newlines.  Therefore, when the template is expanded and the
`xmlo` file is produced, the template produced a `const/@values` with a huge
amount of data on one line.

Then, when another package imports that `xmlo` file via `<import
package="..." />`, which is done via `document()` in XSLT, Saxon takes a
long time to parse it.  60s on my machine for a ~20MiB line.

This problem does not exist for JS fragments; Saxon doesn't mind large text
nodes.  So that is the approach that is taken here.

The template system doesn't have a way to output text yet, so this takes an
approach that minimizes changes as much as possible:

  - `param-copy` will expand `with-param/@value` as a text node.
  - `const/@values="-"` will cause TAME to use the child text node as the
    value of `@values`.
  - `_table-rows_` is modified to use the above two features.

The reason for using `@values="-"` is so that other parts of the compiler do
not have to be modified to recognize the new text convention, which is
otherwise awkward because newlines are text nodes.  The `-` convention comes
from command line programs, which means "read from stdin", generally; this
is okay since `-` is never a valid matrix specification.

This must have been a problem for a very long time, but wasn't all that
noticeable until recent performance optimizations, since so many other things
around it were also slow.

DEV-15131
2023-10-18 11:43:48 -04:00
Mike Gerwitz 954b5a2795 Copyright year and name update
Ryan Specialty Group (RSG) rebranded to Ryan Specialty after its IPO.
2023-01-20 23:37:30 -05:00
Mike Gerwitz 2fcd0b35ae core: vector/cmatch/match-* (@const@): Remove
This removes the deprecated `@const@` argument in favor of shorthand
`@value@` constants, which were introduced long ago precisely to avoid
having to define separate `@const@` parameters for all of these templates.

DEV-7145
2022-08-29 15:52:04 -04:00
Mike Gerwitz 5ee0ddd064 core: list2typedef: Include proper package namespace prefixes
Required by yet-to-be-committed TAMER grammar.

DEV-7145
2022-08-29 15:52:03 -04:00
Mike Gerwitz 6269f8de6e core: Remove @keep
"keep" is an old feature that forced the linker to retain symbols that were
unused.  This was removed long ago in favor of having all linker roots
defined by the return map.

This also removes an old `@always`, which seems like a typo for
`when="always"` or something...not entirely sure.

DEV-7145
2022-08-22 15:02:53 -04:00
Mike Gerwitz acd0aea6a4 core: Remove @accumulate
Accumulators were an ancient TAME feature removed long ago during The Great
Refactoring (...okay, that part didn't fit the definition of a "refactor",
but that's technically what that's referring to).

TAMER will not accept it.

DEV-7145
2022-08-22 15:02:52 -04:00
Mike Gerwitz 9f98cbf9b4 core: Remove `const/@type`
This has been optional for many years and is not actually used by the
current compiler.  TAMER can infer it, in situations where it actually
matters in the future.

So, rather than adding support for this in the new parser, let's clean up.

DEV-7145
2022-08-15 11:57:45 -04:00
Mike Gerwitz 1ad2fb1dc8 Copyright year update 2022
RSG (Ryan Specialty Group) recently announced a rename to Ryan Specialty (no
"Group"), but I'm not sure if the legal name has been changed yet or not, so
I'll wait on that.
2022-05-03 14:14:29 -04:00
Mike Gerwitz 2ea66f4f97 tame: @encoding="{ISO-8859-1=>utf-8}" for all XML-based files
TAMER rejects this, because we shouldn't be using anything but UTF-8.  My
use of this encoding is ancient, from over a decade ago, that was apparently
just copied around.

DEV-10936
2022-05-02 12:00:42 -04:00
Mike Gerwitz 2e50af1220 Copyright year update 2021 2021-07-22 15:00:15 -04:00
Mike Gerwitz 8ce217f779 [DEV-8947] Make mrange fully tail-recursive and enable TCO
We were still having issues with this function when taking the positive
branch, when predicates cause many matches within tables.  This was causing
us to hit stack limits in certain browsers on the Summary Page.

This converts it to an iterator so that all branches are tail-recursive, and
then enables TCO on them.

I was disappointed to find that there's little performance or memory benefit
in running our test suite.
2020-12-09 09:56:43 -05:00
Mike Gerwitz 61aec5f714 [DEV-8130] core: mrange: Use experimental guided TCO
This alleviates stack exhaustion issues with large rate tables where the
predicates fail to reduce the search space to a reasonable size.
2020-07-15 10:33:05 -04:00
Mike Gerwitz 3418023269 core: mrange: Inline _mrange_cmp
This will permit the use of TCO in the following commit.
2020-07-15 10:33:05 -04:00
Mike Gerwitz bfea768f89 Copyright year 2020 update 2020-03-06 11:05:18 -05:00
Mike Gerwitz e97f7a75c9 core/test/vector (_define-vector_): Require description
We want things to require documentation when possible.
2019-10-17 09:20:15 -04:00
Mike Gerwitz 39c7161cca vector/define: New package introducing _define-vector_
This is intended to work around the issue of defining arbitrary vectors
outside of a c:let.
2019-10-17 09:16:45 -04:00
Mike Gerwitz 3e13b733c4 core/vector/cmatch.xml (_classify-vector_): New template
This is the analog of _classify-scalar_.
2019-07-29 14:51:38 -04:00
Mike Gerwitz 26249f8dbb core: Add _vfilter-mask_
* core/test/core/suite.xml: Import `vector/filter'.
* core/test/core/vector/filter.xml: New package.
* core/vector/filter.xml (_vfilter-mask_, _vfilter_mask): New template, function.
2019-02-14 15:05:49 -05:00
Mike Gerwitz 46b7c234dd core: vector/minmax/_minreduce_: New template
* test/core/suite.xml: Import `test/core/vector/minmax'.
* test/core/vector/minmax.xml: New package.
* vector/minmax.xml (_minreduce_, _minreduce): New template, function.
2019-02-13 14:38:08 -05:00
Mike Gerwitz e022a3133d Copyright year simplification and update to Ryan Specialty Group
This now uses year ranges, which I'll update annually.

This also renames "R-T Specialty" to "Ryan Specialty Group".  The latter is
the parent company of the former.  I was originally employed under the
former when LoVullo Associates was purchased, by I now work for the parent
company.
2019-02-07 13:23:09 -05:00
Mike Gerwitz 11109d4361 core: Add _where-*_ query predicate templates
These provide a more pleasent abstraction than having to reference CMP_OP_*
constants.

* core/test/core/vector/interpolate.xml: {t:when=>t:where-eq}.
* core/test/core/vector/table.xml: Likewise, but using the other variants
    where appropriate given the value of `@op'.
* core/vector/interpolate.xml: Likewise.
* core/vector/table.xml (_when_, _where_): Rename former to latter and
    provide deprecation warning.
  (_when-lt_, _when-lte_, _when-gt_, _when-gte_): Add abstractions.
* src/current/rater.xsd: Permit template variable as tenplate name.
2019-02-04 10:22:46 -05:00
Mike Gerwitz 36a3e348b6 core: Add comparison operators for table query predicates
This is fairly primitive support and it completely sidesteps the bisect
algorithm for now.  The next commit will abstract this a little bit further
to make it less awkward to use.

* core/test/core/vector/table.xml: New test cases.
* core/vector/filter.xml (CmpOp): New typedef.
  (mfilter): Document that bisecting will not happen unless `CMP_OP_EQ'
    is used.  Implement that restriction.
    [op]: New parameter.  Provide it to `mrange'.
  (_mfilter, _mrange_cmp): Rename from `_mfilter'.  Implement new comparison
    check based on `op'
    [op]: New argument.
* core/vector/table.xml (_when_)[@op@]: New param.  Add it to the produced
    vector.
  (_mquery): Unpack op (from `_when_') in call to `mfilter'.
2019-02-04 10:22:46 -05:00
Mike Gerwitz 74f8b56fcc Use some modern shorthands for core/vector/{table,filter}
Just trying to clean up a little as I go to start to make it easier
to understand.

* core/vector/filter.xml: Use _when-*_ templates and c:recurse.
* core/vector/table.xml: Likewise.
2019-02-04 10:22:46 -05:00
Mike Gerwitz 73d691273e core: Replace all occurrences of c:{set=>vector}
The former is deprecated and never made any sense at all.
2019-02-01 16:01:56 -05:00
Mike Gerwitz e7528947a4 _classify-scalar_: Fix misspelled {yeilds=>yields}
* vector/cmatch.xml (_classify-scalar_): Typo fix {yeilds=>yields}.
2018-09-11 09:30:53 -04:00
Mike Gerwitz ee179645f7 vector/arithmetic: Remove accidentally committed debug-to-console
Noticed this when running a rater in an interactive terminal.

* vector/arithmetic.xml (_mproduct): Remove `debug-to-console'.
2018-09-11 09:30:53 -04:00
Mike Gerwitz 500fe170d4 _fold-matrix_: Add template
* vector/fold.xml (_fold-matrix_): New template.
2018-09-11 09:30:53 -04:00
Mike Gerwitz 7123f9818a _unfold-vector-grouped_: New template.
* test/core/suite.xml: Import new fold test package.
* test/core/vector/fold.xml: New test package.
* vector/fold.xml: New package.  Adds `_unfold-vector-grouped_'.
2018-09-11 09:30:53 -04:00
Mike Gerwitz a9b9286c9b vector/filter: Add vfilter_lookup
* vector/filter.xml (vfilter_lookup): New function.
2018-09-11 09:30:53 -04:00
Mike Gerwitz a8fd36176d stub: Add sequence vectors.
* vector/stub.xml: Add sequence vectors.
2018-09-11 09:30:53 -04:00
Mike Gerwitz 46c230febb _cons-until-empty_: Add @only@
* vector/list.xml (_cons-until-empty_): Add @only@, which has the opposite
    behavior to @glance@.
  (_merge-until-empty_): Proxy @only@.
2018-09-11 09:30:53 -04:00
Mike Gerwitz 6f891b7b15 vector/filter: Decrease value of TABLE_WHEN_MASK_VALUE
This makes it more unlikely to actually occur in a table lookup;
the previous value worried me.

* vector/filter.xml (TABLE_WHEN_MASK_VALUE): Decrease value.
2018-09-11 09:30:52 -04:00
Mike Gerwitz 98f9b6fadb vector/table: Extract bisect functions into vector/filter
* vector/filter.xml (bisect, foremost, _mask-unless_): Add to package.
* vector/table.xml (bisect, foremost, _mask-unless_): Remove from package.
2018-09-11 09:30:52 -04:00
Mike Gerwitz cac9d22cb2 vector/filter: Formatting and minor doc 2018-09-11 09:30:52 -04:00
Mike Gerwitz ec7d1c2a24 vector/table: Extract mfilter and range into vector/filter
* vector/filter.xml: New package.
* vector/table.xml (mfilter, _mfilter, range): Extract into vector/filter.
2018-09-11 09:30:52 -04:00
Mike Gerwitz 1fa833eb47 {L=>}GPL
I don't recall why I licensed under the LGPL initially.
2018-09-11 09:30:52 -04:00
Mike Gerwitz a1f2b2aad8 vector/cmatch: Deprecate @const@ on shorthand templates
* vector/cmatch: Display warning on use of @const@ with short-hand
  comparison templates.
2018-09-11 09:30:52 -04:00
Mike Gerwitz 5267baa0e9 vector/stub: Add package.
* test/core/vector/stub.xml: Add specification.
* vector/stub.xml: Add package.
2018-09-11 09:30:51 -04:00
Mike Gerwitz ec379ea296 vector/cmatch: Add `_vector-to-class_'
* vector/cmatch.xml: (_vector-to-class_): Add template.
 Lines starting
2018-09-11 09:30:51 -04:00
Mike Gerwitz 088a948891 Update all copyrights from LoVullo to R-T Specialty 2018-09-11 09:30:51 -04:00
Mike Gerwitz 5000e35891 vector/arithmetic: Add _{v,m}product_
Products of vectors and matrices respectively.  It's surprising that this
was unneeded until now based on the requirements of the projects we have
done thusfar---dot products and other features have been sufficient.

* vector/arithmetic.xml (_vproduct_, _mproduct_): New templates.
  (_vproduct, _mproduct): New functions.
2018-09-11 09:30:51 -04:00
Mike Gerwitz 24e578c7ae _cons-until-empty_: Add @index@
This is much more general-purpose and is necessary when operating on more
than one list.

* vector/list.xml: Add numeric/common import, exported.
  (_cons-until-empty_): Add @index@, incremented at each recursion.
2018-09-11 09:30:51 -04:00
Mike Gerwitz b33f8bb999 Add vector/length package
* vector/length.xml: New file.
2018-09-11 09:30:50 -04:00
Mike Gerwitz 7e1b0c6d0d Add _repeat-value_ template
* vector/common.xml (_repeat-value_): Add template.
2018-09-11 09:30:50 -04:00
Arthur Domino 49663c5779 Added missing export in table package for numeric/common 2018-09-11 09:30:50 -04:00
Mike Gerwitz 9805eaf755 Support table data definition via _table-rows_/@data@
This uses the GNU Octave or MATLAB-style matrix definitions for tables,
which produces a single node instead of a node per field and row, which
results in a significantly smaller tree and drastically improves processing
time.
2018-09-11 09:30:49 -04:00
Mike Gerwitz 6a9b9bf2e5 _classify-scalar_ template introduced 2018-09-11 09:30:49 -04:00
Mike Gerwitz 415ab05610 Extracted vector min/max templates/functions from vector/arithmetic
BC incompatible.
2018-09-11 09:30:49 -04:00
Mike Gerwitz a3b6b45df9 LGPL license; copyright notice added to head of each file 2018-09-11 09:30:48 -04:00
Mike Gerwitz fb1416837b Package namespace/imports/decl cleanup 2018-09-11 09:30:48 -04:00