GithubHelp home page GithubHelp logo

Comments (6)

nkovacs avatar nkovacs commented on June 2, 2024

go.rice already uses string literals and it also uses %q for formatting, which means it only encodes characters that need to be encoded (similar to dsymonds/goembed#3). I've benchmarked both goembed and go.rice, the memory usage and elapsed time for a single, 80 megabyte file are quite similar.

rice embed-go:

Elapsed (wall clock) time (h:mm:ss or m:ss): 0:06.37
Maximum resident set size (kbytes): 1988272

go build with file generated by rice:

Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.19
Maximum resident set size (kbytes): 570256

goembed:

Elapsed (wall clock) time (h:mm:ss or m:ss): 0:05.72
Maximum resident set size (kbytes): 7272

go build with file generated by goembed:

Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.47
Maximum resident set size (kbytes): 624816

The only huge difference is the memory required by the rice command.

from go.rice.

stapelberg avatar stapelberg commented on June 2, 2024

Did you also measure resident set size of the compiled program?

from go.rice.

nkovacs avatar nkovacs commented on June 2, 2024

goembed:
Maximum resident set size (kbytes): 87232

rice:
Maximum resident set size (kbytes): 88312

(This is after serving the file, otherwise it won't be loaded into memory)

from go.rice.

nkovacs avatar nkovacs commented on June 2, 2024

The rice command uses that much memory because it reads every file into memory first, then generates the entire source code, then parses that and formats it (so it keeps three copies of the file contents in memory).

from go.rice.

GeertJohan avatar GeertJohan commented on June 2, 2024

So, it looks like some optimizations are possible for the rice command itself.. Probably the first thing would be to make the embed command use streams instead of reading the whole file. I'm quite busy these days, if anyone could pick this up that would be great. It could be a while until I find the time to do so.

-edit: just now reading #92-

from go.rice.

GeertJohan avatar GeertJohan commented on June 2, 2024

Closing this issue in favor of #92

from go.rice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.