Comments (6)
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.
Did you also measure resident set size of the compiled program?
from go.rice.
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.
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.
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.
Closing this issue in favor of #92
from go.rice.
Related Issues (20)
- golang:alpine can not install HOT 1
- Dockerize rice binary HOT 1
- Get fails on Ubuntu 16.04 HOT 5
- Nested html templates. HOT 4
- How to run rice from vendor folder?
- How to link CSS with template in box
- Getting rice-box.go file with byte Array instead of string. HOT 2
- github.com/akavel/rsrc dependency has removed coff.NewRDATA HOT 9
- "rice:command not found" after exec the two go get command HOT 1
- Problems with paths HOT 1
- Asset loading race condition causes unexpected panic
- lotus-miner and lotus-worker installation step error HOT 1
- rice append violates Mach-O file format
- Able to skip overwrite or omit creation/modification time in embed-go
- `rice embed-go` doesn't work for go modules beyond v1?
- Report a coding bug about unused result
- Improvement to the README file
- Go install doesn't work HOT 3
- use go install instead of go get
- Dependency daaku/[email protected] incompatible with Go 1.19 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.rice.