• Jesse Gross's avatar
    runner.go: Truncate inputs that exceed context rather than shifting · c4b34f2a
    Jesse Gross authored
    Previous versions of the runner would truncate inputs to the context
    window before beginning processing. The main processing loop relied
    on this behavior if the context needed to be shifted later (due to
    token generation). If truncation did not occur then invariants
    would be broken, causing crashes or infinite loops.
    
    Later versions attempted to fix these bugs and make the logic less
    subtle so that all inputs could be handled. Truncation was removed
    to make things consistent.
    
    However, truncation is much faster than processing and shifting, so
    removing it caused performance problems when the input vastly exceeded
    the context size. This restores the input truncation as a performance
    optimization while keeping the more robust processing logic.
    
    Fixes #7762
    c4b34f2a
runner.go 24.6 KB