tim Rowledge uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-tpr.156.mcz ==================== Summary ==================== Name: Files-tpr.156 Author: tpr Time: 24 May 2016, 10:00:21.788027 am UUID: a9fad8c9-8c36-480a-8c66-1521c4e1bf16 Ancestors: Files-cmm.155 Add call to the fsync file flushing/synchronising primitive, plus a #sync method to use it. =============== Diff against Files-cmm.155 =============== Item was added: + ----- Method: FileStream>>sync (in category 'file open/close') ----- + sync + "sync the current buffer out to disk." + + self subclassResponsibility + ! Item was added: + ----- Method: StandardFileStream>>primSync: (in category 'primitives') ----- + primSync: id + "Call fsync to really, really, flush pending changes to the disk" + | p | + <primitive: 'primitiveFileSync' module: 'FilePlugin'> + "In some OS's seeking to 0 and back will do a flush. Maybe that will help if we dont have the primitives" + p := self position. + self position: 0; position: p! Item was added: + ----- Method: StandardFileStream>>sync (in category 'read, write, position') ----- + sync + "Really, really, flush pending changes" + ^self primSync: fileID! |
I suppose #sync should do nothing when the FileStream is not writable.
Levente On Tue, 24 May 2016, [hidden email] wrote: > tim Rowledge uploaded a new version of Files to project The Trunk: > http://source.squeak.org/trunk/Files-tpr.156.mcz > > ==================== Summary ==================== > > Name: Files-tpr.156 > Author: tpr > Time: 24 May 2016, 10:00:21.788027 am > UUID: a9fad8c9-8c36-480a-8c66-1521c4e1bf16 > Ancestors: Files-cmm.155 > > Add call to the fsync file flushing/synchronising primitive, plus a #sync method to use it. > > =============== Diff against Files-cmm.155 =============== > > Item was added: > + ----- Method: FileStream>>sync (in category 'file open/close') ----- > + sync > + "sync the current buffer out to disk." > + > + self subclassResponsibility > + ! > > Item was added: > + ----- Method: StandardFileStream>>primSync: (in category 'primitives') ----- > + primSync: id > + "Call fsync to really, really, flush pending changes to the disk" > + | p | > + <primitive: 'primitiveFileSync' module: 'FilePlugin'> > + "In some OS's seeking to 0 and back will do a flush. Maybe that will help if we dont have the primitives" > + p := self position. > + self position: 0; position: p! > > Item was added: > + ----- Method: StandardFileStream>>sync (in category 'read, write, position') ----- > + sync > + "Really, really, flush pending changes" > + ^self primSync: fileID! > > > |
In reply to this post by commits-2
Since I'm not a systems programmer, I wasn't really following the
other discussion. But this does interest me since Magma employs a complex logging / playback mechanism which does depend on the idea that returning from #flush assures all my puts on that Filestreams are truly written to the disk. Should I be using #sync, instead of #flush? Could you succinctly summarize the difference between the two for a lay-person like myself? On Tue, May 24, 2016 at 12:02 PM, <[hidden email]> wrote: > tim Rowledge uploaded a new version of Files to project The Trunk: > http://source.squeak.org/trunk/Files-tpr.156.mcz > > ==================== Summary ==================== > > Name: Files-tpr.156 > Author: tpr > Time: 24 May 2016, 10:00:21.788027 am > UUID: a9fad8c9-8c36-480a-8c66-1521c4e1bf16 > Ancestors: Files-cmm.155 > > Add call to the fsync file flushing/synchronising primitive, plus a #sync method to use it. > > =============== Diff against Files-cmm.155 =============== > > Item was added: > + ----- Method: FileStream>>sync (in category 'file open/close') ----- > + sync > + "sync the current buffer out to disk." > + > + self subclassResponsibility > + ! > > Item was added: > + ----- Method: StandardFileStream>>primSync: (in category 'primitives') ----- > + primSync: id > + "Call fsync to really, really, flush pending changes to the disk" > + | p | > + <primitive: 'primitiveFileSync' module: 'FilePlugin'> > + "In some OS's seeking to 0 and back will do a flush. Maybe that will help if we dont have the primitives" > + p := self position. > + self position: 0; position: p! > > Item was added: > + ----- Method: StandardFileStream>>sync (in category 'read, write, position') ----- > + sync > + "Really, really, flush pending changes" > + ^self primSync: fileID! > > |
> On 24-05-2016, at 12:32 PM, Chris Muller <[hidden email]> wrote: > > Since I'm not a systems programmer, I wasn't really following the > other discussion. But this does interest me since Magma employs a > complex logging / playback mechanism which does depend on the idea > that returning from #flush assures all my puts on that Filestreams are > truly written to the disk. > > Should I be using #sync, instead of #flush? Could you succinctly > summarize the difference between the two for a lay-person like myself? My level of understanding of this is roughly that flush is spelt f-l-u-s-h and sync is spelt s-y-n-c. I don’t understand why a system would ever let things get so out of sync that you would ever need to think of it. When you close a file it seems to me that everything should be cleaned up. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Useful random insult:- Hypnotized as a child and couldn't be woken. |
A little research suggests #sync is a blocking operation, whereas
#flush is non-blocking. So I should probably change Magma's atomic-writing to use #sync.. On Tue, May 24, 2016 at 2:45 PM, tim Rowledge <[hidden email]> wrote: > >> On 24-05-2016, at 12:32 PM, Chris Muller <[hidden email]> wrote: >> >> Since I'm not a systems programmer, I wasn't really following the >> other discussion. But this does interest me since Magma employs a >> complex logging / playback mechanism which does depend on the idea >> that returning from #flush assures all my puts on that Filestreams are >> truly written to the disk. >> >> Should I be using #sync, instead of #flush? Could you succinctly >> summarize the difference between the two for a lay-person like myself? > > My level of understanding of this is roughly that flush is spelt f-l-u-s-h and sync is spelt s-y-n-c. I don’t understand why a system would ever let things get so out of sync that you would ever need to think of it. When you close a file it seems to me that everything should be cleaned up. > > > tim > -- > tim Rowledge; [hidden email]; http://www.rowledge.org/tim > Useful random insult:- Hypnotized as a child and couldn't be woken. > > > |
flush makes sure the information has gone from application memory to OS
RAM cache. It can still be lost if the power is abruptly shut off, but is safe from application crashes. sync makes sure the information has gone to disk. It takes longer, and may involve writing stuff from other apps to disk as well. Your info is usually safe, but the disk may have an internal cache of its own :(. If you want it on disk and can afford the time delay, use sync. On 16-05-24 13:49 , Chris Muller wrote: > A little research suggests #sync is a blocking operation, whereas > #flush is non-blocking. > > So I should probably change Magma's atomic-writing to use #sync.. > > > On Tue, May 24, 2016 at 2:45 PM, tim Rowledge <[hidden email]> wrote: >> >>> On 24-05-2016, at 12:32 PM, Chris Muller <[hidden email]> wrote: >>> >>> Since I'm not a systems programmer, I wasn't really following the >>> other discussion. But this does interest me since Magma employs a >>> complex logging / playback mechanism which does depend on the idea >>> that returning from #flush assures all my puts on that Filestreams are >>> truly written to the disk. >>> >>> Should I be using #sync, instead of #flush? Could you succinctly >>> summarize the difference between the two for a lay-person like myself? >> >> My level of understanding of this is roughly that flush is spelt f-l-u-s-h and sync is spelt s-y-n-c. I don’t understand why a system would ever let things get so out of sync that you would ever need to think of it. When you close a file it seems to me that everything should be cleaned up. >> >> >> tim >> -- >> tim Rowledge; [hidden email]; http://www.rowledge.org/tim >> Useful random insult:- Hypnotized as a child and couldn't be woken. >> >> >> > > -- Tom Rushworth |
Free forum by Nabble | Edit this page |