Comments (5)
Relevant code in Android's Ninja fork. (Not sure how to get a permalink to that commit but the file is unlikely to change much in the future, but it's the function MapFile
.)
from n2.
I wrote a mini benchmark here.
On this Mac Air M2 for a random 1.4gb file:
without madvise
:
./target/release/read-file mmap $F ran
1.25 ± 0.01 times faster than ./target/release/read-file read $F
with madvise
:
./target/release/read-file mmap $F ran
1.36 ± 0.02 times faster than ./target/release/read-file read $F
So I conclude at least for this hw/OS that mmap is faster, and madvise helps too.
from n2.
Relevant code in Android's Ninja fork. (Not sure how to get a permalink to that commit but the file is unlikely to change much in the future, but it's the function
MapFile
.)
Sorry, this link should be permanent.
from n2.
Just a thought regarding "correctness" more than performances.
Is there any risk of the mmaped build.ninja changing during the build?
I had a bad experience trying to mmap user-controlled file, an update of the file at the wrong time could cause my process to crash with SIGBUS.
Edit: it could just be I didn't use the proper type of memory mapping.
The build.ninja file can be regenerated during build by the build system (I think cmake does this when a CMakeLists.txt changes), can this invalidate the memory mapping?
from n2.
can this invalidate the memory mapping?
The Linux man pages says it's undefined behavior. The Mac ones don't say either way. It is true that we wouldn't want to preserve the mapping beyond the point where the file might be rewritten though.
from n2.
Related Issues (20)
- Variable expansion missing global reference
- Difference in behavior with ninja when not specifying a target
- Inconsistent handling of newline escapes HOT 2
- Variable references in build inputs don't take into account the build's bindings HOT 5
- Oversized WriteBuf panic HOT 3
- Validation mode HOT 3
- proper `console` pool support
- better control over subcommand output HOT 2
- `e2e::validations::build_starts_before_validation_finishes` fails every so often HOT 2
- Tag a release (candidate)? HOT 1
- Difficulties with git-lfs HOT 4
- Give priority to slow actions HOT 2
- 10% of parse time is tracking line numbers HOT 4
- Add multithreaded parsing HOT 5
- dry-run mode
- mutable reference to mutable static detected bu rustc HOT 1
- Segmentfault when building fastfetch HOT 5
- Shell-escape $in, $in_newline, $out, and $out_newline
- Native support for remote-execution / caching HOT 3
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 n2.