Subject: | Memory Savings Possible |
Potentially significant memory savings are available when generating a
Math::Curve::Hilbert object, particularly with large (10 or greater, in
particular) settings of "max". In my testing, the attached patch to
change the elements of $self->{coords} from hashrefs to arrayrefs was
sufficient to save ~52MB of memory, going from a virtual size of 357MB
to 305MB. It should also speed up access to values in $self->{coords},
though I haven't benchmarked by how much (since array access is faster
than hash access in Perl).
Note: This patch has not been fully tested against all possible access
methods, only against access by the CoordinatesFromPoint method. I
believe all instances of hash access of $self->{coords} have been
adjusted, though.
More significant savings could be accomplished by removing this
duplication of $self->{curve}/$self->{coords} entirely, though I haven't
yet contemplated an efficient way of doing so. It may be feasible to
simply use reverse and split on $self->{curve}, though that has
significant CPU usage ramifications. I'm very interested in speeding up
creation of Math::Curve::Hilbert objects with a max value of 10, and
would love to hear further suggestions for work in this area.
Subject: | hilbert-mem.patch |
Message body is not shown because it is too large.