agrostis / diff-match-patch

A Common Lisp port of Neil Fraser's library of the same name
Apache License 2.0
9 stars 2 forks source link

Test diff-timeout fails on slow machines, because for *diff-timeout* affects only part of the code #4

Closed Yehouda closed 4 years ago

Yehouda commented 4 years ago

The test diff-timout fails on slow machines, because the code outside diff-bisect (where it calls past-diff-deadline) is not limited by *diff-timeout*.

This specific test fails for slow machines, but it means similar failures for faster machines on more complex diff operations.

It should either have a way to propagate reaching the deadline out of diff-bisect to the callers, or check in other places too.

agrostis commented 4 years ago

Thanks for reporting it. As far as I could make out, the problem was caused by the line-level optimization (diff.lisp, lines 136–139):

      (when (and (stringp a) (stringp b) *diff-check-lines-length*
                 (> (length a) *diff-check-lines-length*)
                 (> (length b) *diff-check-lines-length*))
        (diff-line-mode a b test))

Diff-line-mode abbreviates the inputs by splitting them into lines and replacing the lines with hash indexes. When the inputs are sufficiently large, as in this test, the splitting and hashing takes some time, which is not covered by the diff-bisect timeout mechanism. However, it falls within the time measured by timed-diff in the test.

Solved by switching off the optimization, tested with the interpreter artificially slowed down (cpulimit -l 10 sbcl).