[SLOF] [PATCH] base: increase catpad buffer
Segher Boessenkool
segher at kernel.crashing.org
Tue Nov 28 23:08:23 AEDT 2017
On Tue, Nov 28, 2017 at 03:31:43PM +0530, Nikunj A Dadhania wrote:
> Segher Boessenkool <segher at kernel.crashing.org> writes:
> > On Tue, Nov 28, 2017 at 01:08:09PM +0530, Nikunj A Dadhania wrote:
> >> Current buffer of 1K is not sufficient, and causes exception if more than 20
> >> devices are used with bootindex. Increase the buffer size to 16K
> >
> > Concatenating many strings this way is quadratic in the total length,
> > which is very painful with 1k already but ridiculously slow with 16k.
> > Use a better method? $cat is a nice simple lazy utility word, it is
> > not good for constructing unbounded lists.
>
> : load
> [...]
> set-boot-args s" parse-load " $bootdev $cat strdup evaluate
> ;
>
> Thats where we are hitting the limit. Maybe we can allocate and copy
> both these strings without using the catpad?
Do you need to at all? parse-load wants to have the $bootdev string
as input buffer, so you can do
: load
[...]
set-boot-args
save-source -1 to source-id
$boot-dev dup #ib ! span ! to ib
['] parse-load catch restore-source throw ;
This is just the core of EVALUATE, but calling PARSE-LOAD instead of
INTERPRET.
And yes, this can of course itself be factored better:
: $source ( str len -- ) -1 to source-id dup #ib ! span ! to #ib ;
: execute-with-source ( xt str len -- ??? )
save-source $source catch restore-source throw ;
: load
[...]
['] parse-load $boot-dev execute-with-source ;
\ and evaluate is just:
: evaluate ( str len -- ??? ) ['] interpret -rot execute-with-source ;
Segher
More information about the SLOF
mailing list