[sbt] Change Detection in Continuous Compile Mode

42 views
Skip to first unread message

Randall R Schulz

unread,
May 22, 2010, 5:00:16 PM5/22/10
to simple-b...@googlegroups.com
Hi,

I recently started using the "compile~" command and it made me wonder
about something: When I save my work in IDEA (where there is only "Save
all") and multiple files are changed, how does SBT make sure it sees
all the modified files to decide what to recompile? I imagine a race
condition where it notices one file was changed (though there were
others), begins its dependency analysis and initiates compilation based
solely on the single file that triggered recompilation (and its
dependencies).

Is this scenario possible or does SBT do something to catch several
source files getting modified in quick succession?


Randall Schulz

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Mark Harrah

unread,
May 23, 2010, 4:39:31 PM5/23/10
to simple-b...@googlegroups.com
Hey Randall,

On Saturday 22 May 2010, Randall R Schulz wrote:
> Hi,
>
> I recently started using the "compile~" command and it made me wonder
> about something: When I save my work in IDEA (where there is only "Save
> all") and multiple files are changed, how does SBT make sure it sees
> all the modified files to decide what to recompile? I imagine a race
> condition where it notices one file was changed (though there were
> others), begins its dependency analysis and initiates compilation based
> solely on the single file that triggered recompilation (and its
> dependencies).

I'm not sure it can be completely avoided without cooperation between the editor and sbt. I haven't heard of or seen it being an issue in practice and would be interested to know if it comes up.

sbt polls the last modified time of everything in watchPaths every second or so. This polling is only used to determine when to run an action. The information on which files triggered running the action is not used.

Still, if you modified enough large files and saved them all at once close to the polling time such that a file gets saved before and after polling, you might be able to see an issue. sbt still checks the hash of each source file before compilation, so at least the issue won't accumulate.

-Mark

Randall R Schulz

unread,
May 23, 2010, 5:29:32 PM5/23/10
to simple-b...@googlegroups.com
On Sunday May 23 2010, Mark Harrah wrote:
> Hey Randall,
>
> On Saturday 22 May 2010, Randall R Schulz wrote:
> > Hi,
> >
> > I recently started using the "compile~" command and it made me
> > wonder about something: When I save my work in IDEA (where there is
> > only "Save all") and multiple files are changed, how does SBT make
> > sure it sees all the modified files to decide what to recompile? I
> > imagine a race condition where it notices one file was changed
> > (though there were others), begins its dependency analysis and
> > initiates compilation based solely on the single file that
> > triggered recompilation (and its dependencies).
>
> I'm not sure it can be completely avoided without cooperation between
> the editor and sbt. I haven't heard of or seen it being an issue in
> practice and would be interested to know if it comes up.
>
> ...
>
> -Mark

OK, thanks. I shall not worry further.
Reply all
Reply to author
Forward
0 new messages