Comments (6)
This question asks whether we think we have the wrong default on fileReader / fileWriter as well, and would want to switch it to non-locking, or just remove the default to require the user to think about it.
I agree that in many cases users actually want a non-parallel safe fileReader/fileWriter, and are unaware that this isn't what they're getting; however, I'm somewhat wary of changing the default value in all cases. I'd propose that we make the following changes to make it more likely that users get the locking behavior they want:
- Remove
locking
's default value in thefile.reader
andfile.writer
methods. Since these methods are more amenable to scenarios where multiple readers/writers are being created around the same file, this forces users to think about whether they need parallel safety in those cases. For example:
var f = open("path/to/file.txt", ioMode.r);
coforall tid in 1..nTasks {
var taskReader = f.reader(locking=true, ...);
...
}
note: we could also consider simply keeping the default value of true
for these methods
- Switch the default value to
false
for theopenReader
andopenWriter
standalone procs. In my experience, these are used more commonly in cases where a user only wants one reader/writer to a particular file. For example:
proc getIntFrom(file: string): int throws {
return openReader(filePath).read(int);
}
Additionally, I consider these to be convenience functions, and thus would prefer to have default values for as many arguments as possible.
- Remove the default value for
locking
from the fileReader/fileWriter types themselves, implying that parallel safety should be decided on a situation by situation basis.- As you mentioned above, I agree that
stdin
,stdout
, orstderr
should be parallel safe due to their global nature.
- As you mentioned above, I agree that
from chapel.
Not sure if such a flag would be reasonable to toggle stdin/stdout/stderr having locking or not.
I'm always hesitant to have program behavior depend on a flag that isn't visible in the source code, so of the options, I like the notion of having a fastStdin
or the like instead. That would also permit both fast and safe uses of stdout within a single program, I think. Alternatively, we could have a FastConsole
module or the like whose use/import would define stdin
/stdout
/stderr
to be the fast versions within that scope. But I worry a bit about how that would mix with standard uses of the IO module (and it seems like it could lead to confusion and definitely the inability to mix the two notions of the console in a current scope).
I'll fork this off into its own issue if nobody objects (and I don't find we've already got one).
from chapel.
Only tangentially related, but: Would any of you following this issue so far have any appetite for introducing an unlocked version of stdin/stdout/stderr as part of this effort? (the goal being to have low-overhead shootouts that don't have to rely on the open file 0 trick that we currently have). I think the only hard part is the naming (e.g., stdinUnlocked
? stdinNoLock
? lockFreeStdin
? they all seem clunky...?)
from chapel.
@bradcray - I'd expect we'd also want stdin/stdout/stderr that works directly with the OS rather than using line-buffering and working through a FILE*
. In the past I've considered maybe having a compilation flag (maybe a config param or something?) to opt out of the current mode which could be described as "stdout etc interoperate with C but are slower". Not sure if such a flag would be reasonable to toggle stdin/stdout/stderr having locking or not.
On approach would be to have something like fastStdin
that isn't locking and also disables the C interoperability.
from chapel.
Regarding fastStdout
etc, another thing it might do is to do separate buffering per locale in order to be more efficient in distributed environments. It would give up line-based interleaving of the output from different locales.
from chapel.
This was resolved, closing
from chapel.
Related Issues (20)
- Should we support a low memory sort option HOT 1
- How should `proc sort` handle non-1D/non-rectangular arrays HOT 3
- [Bug]: Rexported symbols like `sqrt` cause issues when imported using `.{..}` HOT 4
- chpl__init_ModuleName(int64_t _ln, int32_t _fn) has mystery parameters HOT 1
- should identifier matches against the enclosing module name be considered if there are other matches? HOT 6
- Performance delta between Chapel and CUDA for `tanh` HOT 2
- `make test-cls` fails in quickstart config on M1 mac
- [Documentation]: Improve GPU Setup Documentation for CHPL_LOCALE_MODEL=gpu HOT 1
- Standalone Arkouda `ContrivedConstructor` caused compiler to throw unreasonable promotion/parameness error HOT 1
- [Feature Request]: Chapel OS packages with GPU support
- Add chpl-language-server documentation for vim and emacs HOT 6
- [Bug]: problems in LLVM or C codegen
- [Documentation]: Should we move the documentation on syntax highlighting into the online documentation? HOT 1
- [Feature Request]: Add support for DuckDB HOT 1
- Compiler LLVM fatal errors aren't very helpful without CHPL_DEVELOPER right now HOT 1
- [Feature Request]: support autocompletion for fish HOT 1
- Dyno: named declarations should report their indentation separately from their name locations
- Remove/Retire 'numa' locale model
- [Feature Request]: Lint rule for extra parentheses HOT 3
- [Feature Request]: Lint rule for line length
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 chapel.