feat(common/core/web): engine correction-prep optimizations#5319
feat(common/core/web): engine correction-prep optimizations#5319
Conversation
See #5312! |
In my experiment, the sliding window was internal to the algorithm -- stored values were all relative to start of string. It was just narrowing the search space. See #5314. |
Refer to Note: #5314 does not include a sliding window on If we do give Later edit: After some extra analysis, I think we can safely build the fat-finger |
|
I've run some performance tests on my mobile. I manually set the textarea to |
|
Bonus! New block of fun: The two ~130ms tests shown there will outright fail at 250ms, rather than the default 2000ms. That may need a bit of tweaking if it turns out my dev machine has more performance than the build agents, of course. Also... that text? It's the full, compiled Web-core script. Figured it was an appropriate candidate for "extremely long text" that's already within the repo. I added in some tests as a mild profiling-check for keystroke rule processing + fat-finger performance. As seen in the screenshot above... by far, the largest impact comes from the base keystroke. The base keystroke still doesn't use a sliding context during rule processing, as we need the full context to provide absolute indexing for determining the I do have work on a local branch aimed to start addressing that if desired, but the work already done is probably an okay place to park things for the moment. |
The VMs for Linux and Windows builds are virtual machines, so performance is likely to vary considerably. |
That's fair. Any preference for the timeout, then? Go with a 'loose' 1 sec? Oh, and BTW - that was under the Linux VM. |
Let's leave it at 250ms and tweak if it proves necessary. |
| } | ||
|
|
||
| let context = new TranscriptionContext(Mock.from(target), this.configuration); | ||
| let context = new ContextWindow(Mock.from(target), this.configuration); |
There was a problem hiding this comment.
Does this need a new reference at the top of the file?
There was a problem hiding this comment.
Definitely one of the "quirks" of the whole <reference path="" /> setup. Since a file that references this makes the new reference first... no, not in a literal sense.
Not saying it's a bad idea, though - adding it may indeed be more clear.
| if(coreSourceCode._kmwLength() > 1000000) { | ||
| coreSourceCode = coreSourceCode._kmwSubstring(0, 1000000); |
There was a problem hiding this comment.
| if(coreSourceCode._kmwLength() > 1000000) { | |
| coreSourceCode = coreSourceCode._kmwSubstring(0, 1000000); | |
| if(coreSourceCode.length() > 1000000) { | |
| coreSourceCode = coreSourceCode.substring(0, 1000000); |
There's really no reason to use kmw forms here is there?
There was a problem hiding this comment.
Eh, that's fair. I used it mostly for cross-unit-test consistency. True, KMW's source code doesn't actually have SMP characters.
There was a problem hiding this comment.
length is a property, not a method, though...
|
Changes in this pull request will be available for download in Keyman version 15.0.74-alpha |
|
Changes in this pull request will be available for download in Keyman version 15.0.83-alpha |


An alternate approach from #5314.
Rather than outright turning off base fat-finger modeling, why not just threshold it within a tight time window? As seen here, it's quite simple to do.
Furthermore, after a bit of investigation as to what could possibly be responsible for #5314's point 3 making such a huge difference... I realized that the core
Mock.fromfunction was likely responsible.Mock.fromdid not get the sliding-context-window treatmentMock.fromrelies on the kmwstring.ts utility functions.The thing is... there's no reason for point 2 to be necessary if provided an initial Mock. Which is the case for modeling potential fat-fingers, even before applying engine rules - so this "simple" optimization should actually have a very significant impact.
In testing, I've noticed that touch-alias elements may still be slow to 'load' whenever they receive focus. TouchAliasElement caret-positioning logic doesn't appear optimized for long text. That's a separate, though related, issue.
While everything needed for a proper "sliding window" approach isn't yet fully clear, I will say that all alternates should probably use the same base for their window. In particular, the starting index (within the context) of all windows should match, even if some keys output longer context than others. (So, no 'extra' sliding based on output.)
Such a rule should help simplify other aspects of the engine - particularly, application of suggestions and reversions - if maintaining existing behavior turns out to be non-trivial when that is introduced.