Re:Appending to a file from multiple processes
by tlb on Wednesday August 03, 2016 @04:20PM
(#12221165)
It's really much better for each process to write to its own file, and the consumer can merge-sort the records.
[ Parent
| on HN ]
Re:Appending to a file from multiple processes
by altano on Wednesday August 03, 2016 @06:09PM
(#12221948)
This is basically how Event Tracing for Windows (ETW) solves the problem very efficiently. It uses InterlockedIncrement() to quickly and with minimal contention have something to merge all the records at the end.
If you're on Windows you should use ETW instead of reinventing it when possible :)
Re:Appending to a file from multiple processes
by adzm on Wednesday August 03, 2016 @06:17PM
(#12221987)
ETW is awesome. Too bad it's been plagued by such an opaque API and all the registration junk. I hear it can be easier to use now, but I'm still not sure if an exe can emit ETW events without having to register every possible event or whatever.
Re:Appending to a file from multiple processes
by hirsin on Thursday August 04, 2016 @03:31AM
(#12224002)
The new ETW format is self-documenting at the expense of some overhead. You can set up hello world in ETW in about three lines of code [1], just create the logging channel and log a string or property bag to it.
1. https://blogs.windows.com/buildingapps/2016/06/10/using-devi...
Re:Appending to a file from multiple processes
by danbruc on Wednesday August 03, 2016 @09:17PM
(#12222727)
I separate merge step to produce a single file would tripple the transfered data volume which might or might not be an issue. But in case the ordering of the records does not matter as suggested in the article and if you can get the consumer to consume several files, it would indeed be the easiest solution to just have several files and then consume then one after another.